Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with linking shared library .dll to Fortran code

Status
Not open for further replies.

kostaskon

Technical User
Mar 28, 2011
10
GR
Hi!

I'm trying to link a .dll file to my fortran code. The dll is a compiled shared library of subroutines. The instructions I've found online seem quite complicated and so far they haven't gotten me very far.

Does anyone have any idea how I should go about it?
 
I forgot to mention, I'm using Compaq Visual Fortran...
 
Unfortunately this doesn't help. I'm actually a step behind that guy. What was given with the library distribution is a compiled dll library that I'm trying to link to my code and some related subroutines that I have compiled to a .lib file.
 
Are you doing this from the command line or using Visual Studio? If Visual Studio, which version? If from the command line, what have you tried so far?
 
To xwb:

I'm running CVF v6.5. What I have tried so far is:
- I have compiled all subroutines given along with the dll in a .lib file
- I have added this lib file to my project.

At this point when I try to compile, I get the errors:
unresolved external symbol _CHAMP@20
unresolved external symbol _GET_CRRES_FLUX@44
where I guess CHAMP and GET_CRRES_FLUX are subroutines that are not included in the lib file and I think should be in the dll.

The problem now is that I can't find a way to link the dll to my project. I have tried changing the various settings at Project->Settings but nothing came out of it.

In the last link that mikrom posted I found this thread that describes a problem similar to my own that, from what I understand, didn't get resolved.

Thanks everyone for the help!
 
_champ@20 refers to the routine champ with 5 parameters
_get_crres_flux@44 has 11 parameters
Basically it is the number that follows divided by 4.

Building a DLL will generate 2 files: a .lib and a .dll

The .lib is a placeholder to help with linking.
The .dll is loaded and then linked with the exe at runtime.

All you need to build the exe is the objects and the .lib. If it links successfully, there are three ways of running it.

1) then copy the .dll into the same directory as the exe
2) Modify the path so that the directory containing the dll is in it.
3) Copy the dll to one of the directories on the path.

Another way of forcing it to link is to add a file with the relevant routine names. Just put a print statement in each one so you know whether it gets called or not. Sometimes, the routines are required for linkage but not used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top