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

Converted Library to Module, now calling Programs gets unresolved symbol error

fbalderasintel
785 Views

I have a program that calls a dll. The dll is a collection of subroutines that when compiled generated a .lib and .dll file. It "exports" only one subroutine,I'll call "subx".I needed to wrap all the subroutines as a Module to make "re-use" of other existing modules withing "subx". The DLL compiles but no longer produces a .lib. I include "use module_subx" in the calling program but it gets an unresolved symbol. What calling program properties do I need to change so that it recognizes a "module" as opposed to a plain subroutine?

I use Fortran v11.1/VS2008

0 Kudos
3 Replies
IDZ_A_Intel
Employee
785 Views

You need to tell the project using the module that it needs to reference the .lib. One way to do this is, in the module, to add:

!DEC$ OBJCOMMENT LIB:'modlibname.lib'

where "modlibname" is the name of your DLL's export library.

Another way is to explicitly name the library in "additional dependencies" in the linker properties of the executable project.

Both of the above also require that the executable project add the path to the .LIB to "additional library directories".

Two other options are:

1) Make the DLL project a "dependent" project of the executable in the same solution

2) Add the .lib as "source file" to the executable project

0 Kudos
fbalderasintel
785 Views

Yes adding!DEC$ OBJCOMMENT LIB:'modlibname.lib' did the trick. This caused a .lib to be created. I dont understand why it stopped being created when I wrapped the subroutines in a Module. But with the .lib the calling program was able to recognize the subroutine.

Thank you

Felix

0 Kudos
IDZ_A_Intel
Employee
785 Views
Adding the OBJCOMMENT directive did not cause the library to be created - that would have been done if you added DLLEXPORT directives to the routines you wanted exported. What this DID do was cause any program that USEd the module to add the library as a linker dependence.
0 Kudos
Reply