Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
13 Views

Access file opened in DLL

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
Highlighted
Black Belt Retired Employee
13 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.

0 Kudos
Highlighted
New Contributor II
13 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.

0 Kudos
Highlighted
Black Belt Retired Employee
13 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.

0 Kudos
Highlighted
New Contributor II
13 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.

0 Kudos
Highlighted
Black Belt Retired Employee
13 Views

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

0 Kudos
Highlighted
New Contributor II
13 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?

0 Kudos
Highlighted
Black Belt Retired Employee
13 Views

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

0 Kudos
Highlighted
New Contributor II
13 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

0 Kudos