Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems with shadow builds and static release linkage
Forum Updated to NodeBB v4.3 + New Features

Problems with shadow builds and static release linkage

Scheduled Pinned Locked Moved Solved General and Desktop
shadow buildstaticreleaselinker
3 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtacc32
    wrote on 23 Nov 2015, 03:54 last edited by qtacc32
    #1

    Hello,

    I'd like to have multiple builds of qt, configured differently.
    I'm using Visual Studio 2013 for that.

    My plan is:
    \build_dev as debug shared
    \build_app1 as release static
    etc.

    \build_dev\qtbase\bin is in my PATH, and \build_app1\qtbase would be added as a new Qt version to the Qt Add-in.

    In \build_app1\qtbase for 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 __imp_?staticMetaObject@QMainWindow@@2UQMetaObject@@B.

    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 :(

    Thank you!

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qtacc32
      wrote on 23 Nov 2015, 05:04 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qtacc32
        wrote on 23 Nov 2015, 15:26 last edited by
        #3

        Whew! I think I got it...

        The mistake was to use the includes of shared \build_dev when building in release.
        There is only one little difference which made everything work: qconfig.h!
        It defines QT_STATIC in the static \build_app1 ...

        The debug config of the project created by the Qt Add-in has to be adjusted a little though:
        Include directory $(QTDIR$)\include =>...\build_dev\qtbase\include.
        Lib directory $(QTDIR$)\lib =>...\build_dev\qtbase\lib.
        The project still uses \build_app1\qtbase as Qt Version.

        That way, the Debug build looks for includes and libs in \build_dev while the Release build looks in \build_app1.
        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...

        1 Reply Last reply
        0

        1/3

        23 Nov 2015, 03:54

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved