Link errors in 64-bit Visual FORTRAN

I have a project that compiles, links and runs fine on a 32-bit windows 7 machine using VS 2010. I recently set up a new machine with a 64-bit version of Windows 8 and VS2012. The program compiles all modules fine, but produces an “unresolved external symbol” error for all of the subroutines and functions in the project. This happens using both the VS IDE and command line compiles.

I suspect some configuration problem on the new machine … Any ideas on fixing this would be appreciated!

Hi Hank,

This error mean that some libraries or object are not being added to your link. Some things to check:

  • All required external libraries are being added
    The directory where the libraries are located is configured
    The libraries added are the same “bitness” as your compile (i.e. 64-bit)
    The same optimization flags you add to the compilation are added to the link since some optimization flags will cause additional PGI libraries to be added.
    Some DLL libraries require you to link and compile dynamically, i.e. “-Bdynamic”

Do you have an example of the unresolved references? Are there other errors such as “can’t find the library”? More details may help me determine which of the above are causing the problem.

  • Mat

Hi Mat,

Thanks for the response. I’ve done some research on the issue and found that the project compiles, links and runs fine when created as a 32-bit console application, but fails at link time with a 64-bit configuration. I examined the BuildLog for each and a excerpts are here:


32-bit project that works:

c:\program files (x86)\pgi\win32\13.8\bin\pgfortran.exe -Wl,
/libpath:“c:\program files (x86)\pgi\win32\13.8\lib” -Wl,
/libpath:“C:\Program Files\PGI\Microsoft Open Tools 11\lib” -Wl,
/libpath:“C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86” -Yl,
“C:\Program Files\PGI\Microsoft Open Tools 11\bin” -g -Bstatic
-o “XXX.exe”

64-bit project that fails:

c:\program files\pgi\win64\13.8\bin\pgfortran.exe -Wl,
/libpath:“c:\program files\pgi\win64\13.8\lib” -Wl,
/libpath:“C:\Program Files\PGI\Microsoft Open Tools 11\lib\amd64” -Wl,
/libpath:“C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64” -Yl,
“C:\Program Files\PGI\Microsoft Open Tools 11\bin\amd64” -g -Bstatic
-o “XXX.exe” "

I’m guessing that the paths to the library folders may not be correct and am doing some experimenting with that. I’ll check your other suggestions as well.

I did create a very simple project with default settings and one subroutine and it compiled and linked properly in 64-bit mode.

I’m guessing that the paths to the library folders may not be correct

No, the paths are fine. They are all pointing to the directories where the 64-bit libraries are located.

Do you have an example of the error?

  • Mat

Hi Mat,

Here are a few errors. There are about 100 modules and they all generate something similar:

Command exit code: 2

Command output: [WIRE.obj : error LNK2001: unresolved external symbol data_

REFLC.obj : error LNK2001: unresolved external symbol data_

SBF.obj : error LNK2001: unresolved external symbol data_

TBF.obj : error LNK2001: unresolved external symbol data_

TRIO.obj : error LNK2019: unresolved external symbol data_ referenced in function trio_

I did just notice that the missing external references all appear to be COMMON block names with underscores added to them.

Are these unused external references? If so, you’ll need to add the flag “-Mnoref_externals” to create weak references.

If they are used, then you’re missing the object that contains them. Do you use modules? If so, then you still need to add the module object file to the link, even if the module doesn’t contain executable code.

  • Mat

Hi Mat,

The external references are common blocks which are used extensively throughout the program. Things are working fine when I use a 32-bit project, but when using the same source code in a 64-bit project I get the link errors.

I’m baffled as to the cause.

Maybe one of the objects didn’t get rebuilt?