Problems with shadow builds and static release linkage
I'd like to have multiple builds of qt, configured differently.
I'm using Visual Studio 2013 for that.
My plan is:
\build_devas debug shared
\build_app1as release static
\build_dev\qtbase\binis in my PATH, and
\build_app1\qtbasewould be added as a new Qt version to the Qt Add-in.
\build_app1\qtbasefor example, I created the symlinks bin, include and mkspecs pointing to
\build_dev\...(and also symlinks for the debug import .libs). That way, applications built in debug mode should use dynamic linking and in release mode, they should use \build_app1 etc. and static linking.
Debug build works fine, but when I try to build in release, I get these linker errors:
moc_MainWindow.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const QMainWindow::staticMetaObject" (__imp_?staticMetaObject@QMainWindow@@2UQMetaObject@@B)
Main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QAE@AAHPAPADH@Z)
MainWindow.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const QAbstractButton::staticMetaObject" (__imp_?staticMetaObject@QAbstractButton@@2UQMetaObject@@B)
Does the Visual Studio add-in even support creating an app with static Qt linkage?
Or is it a problem with my shadow builds and the folder structure I have?
What I found is that if I link with QtWidgetsd.lib, these errors go away! But it's a release build, how can that be?
I checked Qt5Widgets.lib from the static release build and found the symbol
?staticMetaObject@QMainWindow@@2UQMetaObject@@B(without __imp _), then I checked QtWidgetsd.lib from the dynamic debug build and found
What is going on here?
I really hope someone can help me... I've been working the last 2 days on this with little sleep to get this working :(
This post is deleted!
Whew! I think I got it...
The mistake was to use the includes of shared
\build_devwhen building in release.
There is only one little difference which made everything work: qconfig.h!
It defines QT_STATIC in the static
The debug config of the project created by the Qt Add-in has to be adjusted a little though:
The project still uses
\build_app1\qtbaseas Qt Version.
That way, the Debug build looks for includes and libs in
\build_devwhile the Release build looks in
And the .lib symlinks are not necessary anymore, I just kept the bin directory symlink.
Just in case someone else wants to do something like this...