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

Linking fortran apps against a DLL results in unresolved references.

richwarren
Beginner
700 Views
According to some older CVF notes that I've seen, there seems to be a requirement for an "import library" which might be created by a tool makilib
that used to be shipped as part of that olderproduct. Is this still the case?
I amcurrently attempting to linka simplefortran app against our MPI dll
export library (libhpmpi.lib), but continue to get unresolved references.
Many thanks for any help you can offer!
Richard
0 Kudos
4 Replies
Steven_L_Intel1
Employee
700 Views
makilib was to be used only if you had a DLL and no export library. You have the export library, so you need to figure out what the mismatch in expectations is.
0 Kudos
richwarren
Beginner
700 Views

Steve,

Here's the output of dumpbin on my exports library and on the dll itself:

Y:Mergeexportsdebugi386in>dumpbin /EXPORTS libhpmpi.lib | grep mpi_init
_mpi_init@4
_mpi_init_thread@12
_mpi_initialized@8

Y:Mergeexportsdebugi386in>dumpbin /EXPORTS libhpmpi.dll | grep mpi_init
407 162 0011D0FA _mpi_init@4 = @ILT+245(_mpi_init@4)
408 163 0011E11C _mpi_init_thread@12 = @ILT+4375(_mpi_init_thread@12)
409 164 0011E5BD _mpi_initialized@8 = @ILT+5560(_mpi_initialized@8)

Y:Mergeexportsdebugi386in>

The fortran code makes the call which can be seen as an external in the .obj file:

020 00000000 SECT2 notype () External | _MAIN__
tag index 00000022 size 000004E4 lines 0002A52A next function 0000007A
022 00000000 SECT2 notype BeginFunction | .bf
line# 0035 end 0000007C
024 0000003B SECT2 notype .bf or.ef | .lf
025 000004E4 SECT2 notype EndFunction | .ef
line# 00a8
027 00000000 UNDEF notype () External | _for_set_reentrancy
028 00000000 UNDEF notype () External | _mpi_init
029 00000000 UNDEF notype () External | _timer_clear
02A 00000036 DEBUG notype Filename | .file
S:warrenFortranNasParallelNPB2.3b2NPB2.3b2FTft.f

As you can tell from the above, I've set the external interface to be lowercase rather than the default UPPERCASE, so as to match what we tend to expect from Fortran (at least on Unix platforms). What am I missing here?

As a last point, we declare the interface to be __stdcall, e.g.

declspec(export) void __stdcall mpi_init (void *ierr) {...}

Should this be something else for fortran?

Thanks!
0 Kudos
Steven_L_Intel1
Employee
700 Views
For Intel Fortran, __stdcall should not be used. Also, Intel Fortran upcases routine names.
0 Kudos
richwarren
Beginner
700 Views
I believe that I found the solution. The fact that I mentioned our use of __stdcall made me go back to the properties pages and look for the interface options. Sure enough, the "calling convention" tab has the "stdcall reference" option that needed to be set. I'm now able to resolve the externals with my DLL!
0 Kudos
Reply