Vcpkg: Building simple Qt application after installation failed

Created on 12 Jul 2017  路  7Comments  路  Source: microsoft/vcpkg

I've installed the qt5 module and I'm trying to build a simple project with just one file:

#include <QtWidgets/QApplication.h>
#include <QtWidgets/QMainWindow.h>

int main(int argc, char** argv) {
    QApplication app { argc, argv };
    QMainWindow mainWindow;

    mainWindow.show();
    return app.exec();
}

Visual Studio can compile fine, but gives me the following error when linking:

1>------ Build started: Project: Basic, Configuration: Release Win32 ------
1>main.cpp
1>Qt5AxServer.lib(qaxserver.obj) : error LNK2001: unresolved external symbol "class QAxFactory * __cdecl qax_instantiate(void)" (?qax_instantiate@@YAPAVQAxFactory@@XZ)
1>C:\Tests\Qt\QtSamples\Release\Basic.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "Basic.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any ideas how I might solve this?

P.S.: With a Debug build I've got many more linking errors...

I'm using Visual Studio 2017 Community.

Thanks in advance.

port-bug

Most helpful comment

@JackBoosY: I think this:

Qt5AxServer.lib should be moved from lib to lib\manual-link;
Qt5AxServerd.lib should be moved from debug\lib to debug\lib\manual-link;

still needs to be resolved

All 7 comments

So, if I manually delete Qt5AxServer.lib and Qt5AxServerd.lib from <vcpkg>\installed\*\lib and <vcpkg>\installed\*\debug\lib everything works.

I'd like to add that for the Debug configuration, <vcpkg>\installed\*\debug\lib\Qt5Bootstrap.lib should also be deleted. Qt5Bootstrap.lib is linked with MD_DynamicRelease and is only meant for Release builds.

Reading a bit more about Qt, it seems that depending on your use case, you either:

  • Link qtmain.lib (rel) or qtmaind.lib (dbg);
  • Or link Qt5AxServer.lib (rel) or Qt5AxServerd.lib (dbg).

Source: http://doc.qt.io/qt-5/activeqt-server.html

Does vcpkg offer any way of selecting which libs will be included in the linking process?

Does vcpkg offer any way of selecting which libs will be included in the linking process?

Okay, after browsing through some source files and other portfile.cmakes, I think the following probably should happen:

  • debug\lib\Qt5Bootstrap.lib must be deleted;
  • Qt5AxServer.lib should be moved from lib to lib\manual-link;
  • Qt5AxServerd.lib should be moved from debug\lib to debug\lib\manual-link;
  • qtmain.lib should be moved from lib to lib\manual-link;
  • qtmaind.lib should be moved from debug\lib to debug\lib\manual-link;

Users need to:

  • Explicitly add qtmain.lib/qtmaind.lib as a dependency for Qt desktop applications for release/debug configurations.
  • Explicitly add Qt5AxServer.lib/Qt5AxServerd.lib as a dependency for Qt ActiveX server applications for release/debug configurations.

Hi @usernameiwantedwasalreadytaken, thanks for reporting this issue.
Since qt5 has been upgraded to 5.12.5, this issue may be fixed.
So please update vcpkg and rebuild qt5.

Thanks.

@Neumann-A I think this issue is resolved in some PRs, is it correct?

@JackBoosY: I think this:

Qt5AxServer.lib should be moved from lib to lib\manual-link;
Qt5AxServerd.lib should be moved from debug\lib to debug\lib\manual-link;

still needs to be resolved

Was this page helpful?
0 / 5 - 0 ratings