Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
143 Views

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

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
Highlighted
Beginner
18 Views

Steve, thanks for the late-in-the-day follow up. We've learned a lot from the assistance, and we're grateful to keep trying fixes as they're offered. If it's of any use: 

1. Specific to the wrapper, if I comment out the single call to the FORTRAN library, then I can successfully build the (albeit neutered) wrapper.

2. Specific to the FORTRAN project, by changing select settings (e.g., multithread to qwin) I am able to successfully build an x64 release exe (no wrapper involved; but not an acceptable workaround for us). 

I interpret these items as signs that we're on the right track by treating the wrapper (and specifically, the linking) as the culprit.

0 Kudos
Highlighted
Beginner
18 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
Highlighted
18 Views

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

Retired 12/31/2016
0 Kudos