Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1,931 Views

unresolved external symbol __imp_* when linking static library

Hi

our application uses the pixman/cairo libraries. I downloaded and compiled pixman/cairo (Release, x64, static .lib, Intel C++ 16.0, inside VS 2013, on Windows 7x64).

Afterwards, I wrote the paths for the include files and for the generated libraries in the project properties of our main application (also Release, x64, Intel C++ 16.0, on Windows 7x64). The files compile fine, but then I get a few linker error messages like:

error LNK2001: unresolved external symbol __imp_cairo_surface_destroy

I double checked the paths and the library names, and they are ok, in the sense that altering them imply linker errors generation (library not found).

What am I doing wrong?

Thanks in advance!

Kind regards,

Pablo

Additional information that might be useful:

Compile options for the library are:

/GS- /W3 /Gy /Zc:wchar_t /Zi /O2 /Fd"x64\Release\vc120.pdb" /fp:fast /D "WIN32" /D "NDEBUG" /D "_LIB" /D "_WINDOWS" /D "CAIRO_NO_MUTEX" /D "_MBCS" /Qipo /GF /Zc:forScope /arch:SSE3 /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\cairo_1_15_2.pch"

Librarian options for the library are:

/OUT:"D:\Source\branches\OCTSoftware\4.4\C++\cairo\vscairo\projects\x64\Release\cairo_1_15_2.lib" /LTCG /MACHINE:X64 /NOLOGO

Compile options for the main application are:

/MP /GS- /TP /Qopenmp /Qrestrict /Qfp-trap:none /W3 /QxSSSE3 /Gy /Zc:wchar_t /I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\\mkl\include" /I"..\..\libtiff\libtiff" /I"..\..\cairo\vscairo\cairo-1.15.2\src" /I"..\..\tinyxml2-master" /I"..\..\eigen-3.2" /I"D:\boost_1_56_0" /I"..\Common" /I"..\StackWalker" /I"..\SpectralRadar" /O2 /Fd"x64\Release\vc120.pdb" /fp:fast /Quse-intel-optimized-headers /D "NO_ORDER4" /D "NO_CONSOLE_LOGGING" /D "_NEW_FILEHANDLER" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "SPECTRALRADAR_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Qstd=c++11 /GF /Zc:forScope /GR /arch:SSE3 /Oi /MD /QaxCORE-AVX-I /Fa"x64\Release\" /EHsc /nologo /Qparallel /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Ot /Fp"x64\Release\SpectralRadar.pch"

Linker options for the application are:

/OUT:"D:\Source\branches\OCTSoftware\4.4\C++\SpectralRadar\x64\Release\SpectralRadar.dll" /MANIFEST /NXCOMPAT /PDB:"D:\Source\branches\OCTSoftware\4.4\C++\SpectralRadar\x64\Release\SpectralRadar.pdb" /DYNAMICBASE "tinyxml2.lib" "microzip.lib" "gdiplus.lib" "Shlwapi.lib" "libtiff.lib" "cairo_1_15_2.lib" "pixman_0_33_6.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"D:\Source\branches\OCTSoftware\4.4\C++\SpectralRadar\x64\Release\SpectralRadar.lib" /DLL /MACHINE:X64 /NODEFAULTLIB:"libcmt.lib" /NODEFAULTLIB:"libcpmt.lib" /OPT:REF /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\SpectralRadar.dll.intermediate.manifest" /OPT:ICF /NOLOGO /LIBPATH:"..\..\fftw-3.3-dll64" /LIBPATH:"..\..\libtiff\libtiff" /LIBPATH:"..\..\cairo\vscairo\projects\x64\Release\" /LIBPATH:"..\x64\Release" /LIBPATH:"..\..\tinyxml2-master\tinyxml2\x64\Release" /LIBPATH:"Release" /LIBPATH:"D:\boost_1_56_0\stage\lib64\" /LIBPATH:"..\..\mkl" /LIBPATH:"..\..\lib\x64\Release" /TLBID:1

 

0 Kudos
4 Replies
Highlighted
Moderator
1,931 Views

  1. is the symbol defined in the static .lib? can you verify with "dumpbin"?
  2. Does the "debug" configuration build ok?
  3. Next question is: does the "release" config build ok without /Qipo?

Jennifer

0 Kudos
Highlighted
Beginner
1,931 Views

Hello

dumpbin reports the function names in the static lib without the __imp_ prefix.

It turned out that the include file (seen by the application to be linked against the static library) had a __declspec(dllimport) specification, whereas a __declspec(dllexport) was needed. I'm rather new to Windows and I did not know this important detail. Changing that detail, and rebuilding everything from scratch, solves the problem.

Before that change (dllimport -> dllexport) the debug version also failed, which I find now reasonable. I did not try turning the /Qipo switch off.

Thans a lot for your help, Jennifer.

Kinds regards,

Pablo

 

0 Kudos
Highlighted
Moderator
1,931 Views

no problem. Good to hear you got it fixed. in this case /Qipo shouldn't have anything to do with this link error.

Jennifer

0 Kudos
Highlighted
Beginner
1,931 Views

I am also facing the same issue:

error LNK2019: unresolved external symbol __imp__xxxx

But, as I verified both __declspec(dllimport) and __declspec(dllexport) are in place.

Any idea where I may be going wrong?

Thanks in advance!

Regards,

Anand

0 Kudos