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

Error LNK2001: Unresolved external symbol when calling a FORTRAN subroutine in a FORTRAN 64-bit library from a 64-bit C Wrapper

Michael_D_7
Beginner
4,184 Views

I have a C wrapper that has always been 32-bit.  It calls a FORTRAN subroutine. This FORTRAN subroutine is in a FORTRAN library (MyFortranLibrary_lib.lib).  This FORTRAN library file has also always been 32-bit. Everything has always worked fine.  However, I have recently changed both the FORTRAN library and the C Wrapper from 32-bit to 64-bit.  I have done this by simply changing the "Active Solution Platform" setting in visual studio from "win32" to "x64" for the C Wrapper and the corresponding setting in the FORTRAN library TO x64. The FORTRAN library compiles fine, without error.

The problem is with the C Wrapper.  When I compile the C Wrapper (and thus try to link it to this 64-bit FORTRAN library), i get A LOT of errors of type "error LNK2001: unresolved external symbol for _something_something_somthing..... So it would appear that there is something further I must do to make things "play nice" between the C Wrapper and FORTRAN library, in the 64-bit world.

Here's a sample of the these LNK errors:

MyFortranLibrary_lib.lib(SomeObject1.obj) : error LNK2001: unresolved external symbol for_check_mult_overflow64
1>MyFortranLibrary_lib.lib(SomeObject2.obj) : error LNK2001: unresolved external symbol for_check_mult_overflow64
1>MyFortranLibrary_lib.lib(SomeObject1.obj) : error LNK2001: unresolved external symbol for_alloc_allocatable
1>MyFortranLibrary_lib.lib(SomeObject2.obj) : error LNK2001: unresolved external symbol for_alloc_allocatable
1>MyFortranLibrary_lib.lib(SomeObject1.obj) : error LNK2001: unresolved external symbol for_dealloc_allocatable
1>MyFortranLibrary_lib.lib(SomeObject3.obj) : error LNK2001: unresolved external symbol for_write_seq_fmt
1>MyFortranLibrary_lib.lib(SomeObject4.obj) : error LNK2001: unresolved external symbol for_write_seq_fmt
1>MyFortranLibrary_lib.lib(SomeObject5.obj) : error LNK2001: unresolved external symbol for_write_seq_fmt

Any help in troubleshooting would be GREATLY APPRECIATED!!!!! I'm seriously racking my brain on this one....

0 Kudos
22 Replies
Michael_D_7
Beginner
548 Views

Eureka! Hey guys, we were able to get it to build; there were some manually placed (ancient by tech standards) libraries local to the .sln directory of the wrapper (duhhhh!). I am so sorry for not noticing this straight-away, and we did learn a ton from this process. For example, prior to running through the suggestions you provided, I was essentially blind to those manually placed (ancient) lib files.

Many thanks, and please no need for any further assistance on this particular issue. 

0 Kudos
Steven_L_Intel1
Employee
548 Views

That was going to be my next guess, as I've seen that before. Glad to hear you sorted it.

0 Kudos
Reply