PDA

View Full Version : Linker error... What am i doing wrong?



hickscorp
20th April 2012, 21:12
Hello,

Back from my unsuccessful journey with MinGW-w64, i just installed a clean Windows XP virtual machine and Visual Studio 2008.
I also have installed the latest Qt SDK with Qt Desktop 4.8.1 compiled for MSVC2008.
In one of my project, i have platform-specific code to dynamically load a windows library (Via LoadLibrary(), GetProcAddress() and FreeLibrary()). So in my project file, i use:


win32 {
LIBS += -lws2_32 -luser32 -lkernel32
}

However, the linker complains:


SCLibrary.cpp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
..\..\PQRRS\SCLibrary\src\SCLibrary.cpp(22) : warning C4007: 'DllMain' : must be '__stdcall'
..\..\PQRRS\SCLibrary\src\SCLibrary.cpp(22) : warning C4100: 'lpvReserved' : unreferenced formal parameter
CanonCR180Controller.cpp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
moc_CanonCR180Controller.cpp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
Creating library ..\..\PQRRS\Debug\SCLibrary.lib and object ..\..\PQRRS\Debug\SCLibrary.exp
CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__FreeLibrary referenced in function "public: virtual __thiscall SC::CanonCR180Controller::~CanonCR180Controller(vo id)" (??1CanonCR180Controller@SC@@UAE@XZ)
CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__GetProcAddress referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__GetLastError referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__LoadLibraryW referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
..\..\PQRRS\Debug\SCLibrary.dll : fatal error LNK1120: 4 unresolved externals
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQ t" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SCLibrary.obj. 1820.10.jom
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQ t" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\CanonCR180Cont roller.obj.1820.1242.jom
C:\QtSDK\Desktop\Qt\4.8.1\msvc2008\bin\moc.exe -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQ t" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -D_MSC_VER=1500 -DWIN32 ..\..\PQRRS\SCLibrary\src\Controllers\CanonCR180Co ntroller.h -o debug\moc_CanonCR180Controller.cpp
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQ t" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\moc_CanonCR180 Controller.obj.1820.2303.jom
link /LIBPATH:"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\SCLibrary.intermediate.manifest" /OUT:..\..\PQRRS\Debug\SCLibrary.dll @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SCLibrary.dll. 1820.3245.jom
C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
cd RELibrary\ && C:\QtSDK\QtCreator\bin\jom.exe -f Makefile
cd SCLibrary\ && C:\QtSDK\QtCreator\bin\jom.exe -f Makefile
jom: C:\Home\Documents\PQRRS\Debug\SCLibrary\Makefile.D ebug [..\..\PQRRS\Debug\SCLibrary.dll] Error 1120
jom: C:\Home\Documents\PQRRS\Debug\SCLibrary\Makefile [debug] Error 2

jom 1.0.8 - empower your cores

jom: C:\Home\Documents\PQRRS\Debug\Makefile [sub-SCLibrary-make_default-ordered] Error 2
22:06:11: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
Error while building project Recognition Suite (target: Desktop)
When executing build step 'Make'


Is there anyone with a clue of what i'm doing wrong please?

Thanks,
Pierre.

amleto
21st April 2012, 11:57
the unresolved symbols might be because of the prior warnings.

looking here, they suggest some qmake compiler flags to try - HTH!
http://qt-project.org/forums/viewthread/15938,


You can add following line to your .pro file.
QMAKE_CFLAGS += /Gz
QMAKE_CXXFLAGS += /Gz

hickscorp
22nd April 2012, 01:31
Hello, and thank you for your answer,

Something was very wrong with the order i was including windows.h and friends... i removed all includes, and eliminated every non-required one related to windows. Now everything works, and linking no longer display those messages.

Thanks,
Pierre.