Pregunta

I am trying to identify why I am receiving an error when linking a static library which has a class containing type-bound procedures.

When I compile and link on the command-line:

This works (and the resulting executable runs properly)

ifort src/main.F90 C:\Temp\lib\test.lib /include:"C:\Temp\mod" $(Opts) /link $(Lnk)

but This does NOT work

ifort src/main.F90 /include:"C:\Temp\mod" $(Opts) /link /LIBPATH:"C:\Temp\lib\test.lib" $(Lnk)

I'd appreciate any suggestions on why the latter command does not work. It is the commandline format by which I link typical libraries. The link errors below from the latter command refer to the type-bound procedures of the Fortran class definition that is contained in test.lib.

(note that ifort and linker versions are contained below. The platform is Windows 7 and I am using make via MinGW in both of the above cases)

ifort src/main.F90  /include:"C:\Temp\mod" /fpe:0 /real_size:64 /integer_size:64 /names:lowercase /iface:cref /iface:mixed_str_len_arg /assume:byterecl /extend_source:132 /O3 /traceback  /INCREMENTAL:NO /link /LIBPATH:"C:\Temp\lib\test.lib" /STACK:100000000 /MAP /MANIFEST /NODEFAULTLIB:msvcrt.lib
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:main.exe 
-subsystem:console 
-incremental:no 
/LIBPATH:C:\Temp\lib\test.lib 
/STACK:100000000 
/MAP 
/MANIFEST 
/NODEFAULTLIB:msvcrt.lib 
main.obj 
main.obj : error LNK2019: unresolved external symbol test_module_mp_setsegmentvalue_8 referenced in function MAIN__
main.obj : error LNK2019: unresolved external symbol test_module_mp_getsegmentvalue referenced in function MAIN__
main.obj : error LNK2001: unresolved external symbol test_module_mp_setsegmentvalue_4
main.exe : fatal error LNK1120: 3 unresolved externals
make: *** [main] Error 1120
makefile:7: recipe for target `main' failed
¿Fue útil?

Solución

The /LIBPATH linker option specifies a directory in which to search for libraries. The second command appears to be using it to specify the library file itself.

Either delete the /LIBPATH: option prefix from the command line, or split the library name from the directory search specification - /LIBPATH:"C:\Temp\lib" ..... test.lib.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top