Getting unresolved externals with static version 4.8.0
-
Hello fellas, before i ask my question, i just want to make one thing clear...
I am using the LGPL version of Qt, and I KNOW this license does not allow me to redistribute my applications statically linked to Qt, But I am not violating this agreement because i use Qt for my own personal learning only. i do NOT redistribute ANYTHING built with Qt.
My Professional (work) development is done with C#, and the .net framework.
Im currently learning Qt, to see if it fits my professional needs, and if i like it. and if it does, in the future i will consider buying a proper comercial license. (and replace my main development tools from C#/.Net to C++/Qt).Now, with that out of the way, heres the thing:
I decided to use Visual Studio 2008 Professional to learn Qt instead of Qt Creator (im allready very familiar with VS).
So after uninstalling the Qt SDK wich i had installed before, i did the following to setup my Qt enviroment, ill try to be as specific as possible:A.- i downloaded and installed the qt-win-opensource-4.8.0-vs2008.exe package, to D:\Qt
B.- i downloaded and installed the Visual studio addin qt-vs-addin-1.1.10.exe to its default location (in program files).
At this point, everything worked fine. i was able to compile and create my Qt apps from the tutorials ibe been reading.
But i decided i want to try it with a statically linked version of Qt, so i did some (ok a lot) of reading in several places and what i did exactly was:1.- Downloaded the 2.8.0 source code .zip package (qt-everywhere-opensource-src-4.8.0.zip)
2.- Extracted the package to D:\Qt\4.8.0-static so now my Qt dir has 2 directories:
D:\Qt\4.8.0\ -- normal shared qt installed from the binary package
D:\Qt\4.8.0-static\ -- place where i extracted the qt-everywhere-opensource-src-4.8.0.zip package3.- I went into D:\Qt\4.8.0-static\bin\ and deleted files syncqt and syncqt.bat, to avoid the "need perl" errors.
4.- Following the instructions found "here":http://developer.qt.nokia.com/wiki/Build_Standalone_Qt_Application_for_Windows, i opened my visual studio 2008 command prompt (32 bit), CD to D:\Qt\4.8.0-static and did:
5.- @configure -static -release -platform win32-msvc@
i only had to change win32-msvc to win32-msvc2008, otherwise it wouldnt work. it took about 10 minutes, and said qt is now configured, bla bla bla (no errors at all)
6.- @nmake sub-src@
took about 20 minutes, and compilation seemed to go ok. got no errors at all.
7.- I opened visual studio, and on the Qt menu->Qt Options->Qt Versions, i added a new one named "4.8.0-static Release", pointing at D:\Qt\4.8.0-static
8.- To test the setup, i created a new Qt Application project with the visual studio wizzard, just a basic GUI app, with a mainwindow.
9.- Changed my configuration to Release, and on menu Qt->Qt Project settings, i changed Version from default 4.8.0 to 4.8.0-static Release
10.- Build the app, no errors at all during compile, but i got 11 unresolved externals.
@Error 1 error LNK2019: unresolved external symbol _WSAAsyncSelect@16 referenced in function "public: void __thiscall QEventDispatcherWin32Private::doWsaAsyncSelect(int)" (?doWsaAsyncSelect@QEventDispatcherWin32Private@@QAEXH@Z) QtCore.lib StaticTestApp@
@Error 2 error LNK2019: unresolved external symbol __imp__PlaySoundW@12 referenced in function "public: static void __cdecl QAccessible::updateAccessibility(class QObject *,int,enum QAccessible::Event)" (?updateAccessibility@QAccessible@@SAXPAVQObject@@HW4Event@1@@Z) QtGui.lib StaticTestApp@
@Error 3 error LNK2019: unresolved external symbol ImmGetDefaultIMEWnd@4 referenced in function "struct HWND_ * cdecl getDefaultIMEWnd(struct HWND *)" (?getDefaultIMEWnd@@YAPAUHWND__@@PAU1@@Z) QtGui.lib StaticTestApp@
i only pasted the first 3 to keep it brief, but all the others were pointing to QtGui.lib
My linker command line in visual studio is this:
@
/OUT:"D:\User\Code\proyectos\StaticTestApp\Release\StaticTestApp.exe" /NOLOGO /LIBPATH:"D:\Qt\4.8.0-static\lib" /MANIFEST /MANIFESTFILE:"D:\User\Code\proyectos\StaticTestApp\Release\StaticTestApp.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /ERRORREPORT:PROMPT qtmain.lib QtCore.lib QtGui.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@As far as i can tell, the linker is looking for the .libs in the right place ("D:\Qt\4.8.0-static\lib")
¿Did i miss something?Needless to say, the same project compiles and links fine with the shared version of Qt, i only get this errors when i try static linking.
Any help appreciated, and thanks for reading this rather long post :)
-
I am having exactly the same problem than you. Have you had any luck with this?
Is there anybody that can help?
-
Under the project settings/Linker/Input/Additional Dependencies, did you add the *.lib files there?
-
Same here.
After a little googling, I found out that adding:
Imm32.lib;Winmm.lib;ws2_32.lib
to:
Linker -> Input -> Additional Dependencies
solves this.I use Windows 7 x64, Visual Studio 2010 and Qt 4.8.1 x64. Shared build works just fine (without adding anything).
BTW, the other necessary lib-s are added automatically by Qt's Visual Studio add-in, if you check them at Qt -> Qt Project Settings -> Qt Modules.