Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

File I/O from a dll

ronald_charlton
Beginner
1,031 Views

Hi,

I am evaluating the Intel compiler under windows to overcome a problem. We need to write error and tracking data into a file from a dll that we have created. When we open the file in the main program and pass the LUN to the dll the write statement in the dll open a new file "fort.lun" and sneds the data to there instead of the file originally opened by the main code.

I have tried a few different options in compiling the main code and the dll but I continue to get the same result. IS this an issue with FORTRAN on windows or am I just doing something wrong.

Thanks for any insite or help you can provide.

Ron C.

0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,031 Views

The solution is to specify that the executable project links against the DLL form of the Fortran run-time libraries. if you don't do this, it uses the static library and then you have two separate copies of the library, neither of which knows the other. Project > Properties > Fortran > Libraries > Use Run-Time Library > Multithreaded DLL. (Use the same setting as for the DLL project.)

0 Kudos
ronald_charlton
Beginner
1,031 Views

The solution is to specify that the executable project links against the DLL form of the Fortran run-time libraries. if you don't do this, it uses the static library and then you have two separate copies of the library, neither of which knows the other. Project > Properties > Fortran > Libraries > Use Run-Time Library > Multithreaded DLL. (Use the same setting as for the DLL project.)


That is one of the options I tried. I just went back to check it again, and I still get the same results. I am building the dll in a project that is separate from the main executable. I copy the dll over into the build directory where the executable is built. I have checked the dllandexecutable dependencies with dumpbin and they appear to use the same library.

Am I missing something?

0 Kudos
Steven_L_Intel1
Employee
1,031 Views
Hard to say - the explanation I gave is the only one that comes to mind. Dumpbin won't, I don't think, tell you what you need. Dependency Walker will. You want both the EXE and the DLL to be using the same libifcorexx.dll.
0 Kudos
ronald_charlton
Beginner
1,031 Views
Hard to say - the explanation I gave is the only one that comes to mind. Dumpbin won't, I don't think, tell you what you need. Dependency Walker will. You want both the EXE and the DLL to be using the same libifcorexx.dll.

I downloaded a trial for VS2008 and IVF to test this here at home. Once I had both the dll and the terminal code configured to use dynamic libraries it worked.

I am running this on a segregated development environment where I think perhaps the installation of the trial got messed up. We have several different compilers and different versions of VS installed on this machine.

Thanks for your help. The dependency walker makes finding somethign like this easy.

Ron C.

0 Kudos
Steven_L_Intel1
Employee
1,031 Views

Glad to be of service.

0 Kudos
lklawrie
Beginner
1,031 Views
One way I have done this is to have the calling program call a routine in the DLL that opens the file.
Just a thought.
Linda
0 Kudos
Reply