Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Access file opened in DLL

gib
New Contributor II
120 Views

The main program uses modules that are built in a DLL.  One of the DLL procedures opens a log file.  I'd like to be able to write to the log file from the main program.  I can make the file unit number known to the main program via !DEC$ ATTRIBUTES DLLEXPORT, but of course that doesn't do anything for me - lines written to unit number 11 just go to fort.11.  Is there a simple way to do what I want to do?

Thanks

Gib

0 Kudos
8 Replies
Steve_Lionel
Black Belt Retired Employee
120 Views

Yes - make sure that your main program links against the DLL form of the Intel run-time libraries. This has been the default in Visual Studio for several releases now, but an older project may not have it. (Your DLL must also link to the DLL libraries.) The project property for this is Fortran > Libraries > Use Runtime Library > Multithread DLL. Make sure that both your DLL and the main program have the same setting here.

What's happening is that your main program and your DLL each have their own copy of the run-time library, so they don't talk to each other.

gib
New Contributor II
120 Views

I changed the main program project property from Multithread to Multithread DLL, but when I run the program I get this error:

Runtime Error!

R6034

An application has made an attempt to load the C runtime library incorrectly.

Maybe my compiler version (11.0.075) is too old for this to work.  I know, you'll say my compiler is obsolete, but it works fine for my purposes.

Steve_Lionel
Black Belt Retired Employee
120 Views

1) Make sure your DLL project has the same setting. Don't mix debug and non-debug.

2) If you have any OTHER projects (C/C++, for example) in the application, make sure that their setting for runtime libraries also matches.

gib
New Contributor II
120 Views

Steve, both the DLL and the main project are Release, both use Multithread DLL, and there are no other projects in the application. Only Fortran.

Steve_Lionel
Black Belt Retired Employee
120 Views

The error you saw occurs when there is a mixture of C library types. Make sure that you are activating the correct DLL.

gib
New Contributor II
120 Views

I checked that the correct DLL is linked.  Dependency Walker doesn't show anything odd, as far as I can tell.  Both the DLL and the exe use c:\windows\system32\MSVCRT.DLL.  Are there other libraries I should look for?

Steve_Lionel
Black Belt Retired Employee
120 Views

But are you running against the correct DLL? If so, then I have no other suggestions.

gib
New Contributor II
120 Views

Copying the DLL into the directory where I execute the program at the command line doesn't help.

Thanks for trying to help.  It isn't a big deal anyway.

Cheers, Gib

Reply