Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT 5.11 from source statically linked using CMake issues



  • Hey,

    I'm currently trying to create a project with statically linked QT built from source.
    I'm using CMake, and I'm getting lots of different unresolved external symbol erros due to some mussing libs I guess.

    I've tried to add one lib after another and now I can't find the rest.

    Currently my CMake libraries looks like this

    sQT
            target_link_libraries(${PROJECT_NAME} PUBLIC
                    Qt5::Core
                    Qt5::Quick
                    Qt5::Multimedia
                    Qt5::QuickControls2
                    Qt5::Widgets
                    )
    
     target_link_libraries(${PROJECT_NAME} PRIVATE
                    sQt
                    Ws2_32.lib
                    Version.lib
                    C:/qt_src/install/lib/qtharfbuzzd.lib
                    C:/qt_src/install/lib/qtlibpngd.lib
                    C:/qt_src/install/lib/qtpcre2d.lib
                    Netapi32.lib
                    userenv.lib
                    C:/qt_src/install/plugins/platforms/qwindowsd.lib
                    C:/qt_src/install/lib/qtfreetyped.lib
                    C:/qt_src/install/lib/libEGLd.lib
                    C:/qt_src/install/lib/libGLESv2d.lib
                    winmm.lib
                    imm32.lib
                    )
    

    And I'm still getting plentyt of those issues but can't find the correct libs to add:

    qwindowsd.lib(qwindowsintegration.obj) : error LNK2019: unresolved external symbol "public: __cdecl QWindowsFontDatabase::QWindowsFontDatabase(void)" (??0QWindowsFontDatabase@@QEAA@XZ) referenced in function "public: virtual class QPlatformFontDatabase * __cdecl QWindowsIntegration::fontDatabase(void)const " (?fontDatabase@QWindowsIntegration@@UEBAPEAVQPlatformFontDatabase@@XZ)
    qwindowsd.lib(qwindowsintegration.obj) : error LNK2019: unresolved external symbol "public: static double __cdecl QWindowsFontDatabase::fontSmoothingGamma(void)" (?fontSmoothingGamma@QWindowsFontDatabase@@SANXZ) referenced in function "public: virtual class QVariant __cdecl QWindowsIntegration::styleHint(enum QPlatformIntegration::StyleHint)const " (?styleHint@QWindowsIntegration@@UEBA?AVQVariant@@W4StyleHint@QPlatformIntegration@@@Z)
    qwindowsd.lib(qwindowsintegration.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl QWindowsFontDatabase::setFontOptions(unsigned int)" (?setFontOptions@QWindowsFontDatabase@@SAXI@Z) referenced in function "public: __cdecl QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(class QStringList const &)" (??0QWindowsIntegrationPrivate@@QEAA@AEBVQStringList@@@Z)
    qwindowsd.lib(qwindowsintegration.obj) : error LNK2001: unresolved external symbol "public: virtual void __cdecl QFreeTypeFontDatabase::populateFontDatabase(void)" (?populateFontDatabase@QFreeTypeFontDatabase@@UEAAXXZ)
    qwindowsd.lib(qwindowsintegration.obj) : error LNK2001: unresolved external symbol "public: virtual class QFontEngine * __cdecl QFreeTypeFontDatabase::fontEngine(struct QFontDef const &,void *)" (?fontEngine@QFreeTypeFontDatabase@@UEAAPEAVQFontEngine@@AEBUQFontDef@@PEAX@Z)
    and more........ (seems like I'm not allowed to post the whole thing)
    
    
    
    those errors are getting out of control and i would need some help
    
    thanks
    slei~


  • #include <QApplication>
    #include <QPushButton>
    
    #include <QtPlugin>
    Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
    
    int main(int argc, char *argv[])
    {
     QApplication app (argc, argv);
    
     QPushButton button ("Hello world !");
     button.show();
    
     return app.exec();
    }
    

    I've also added the plugin stuff on top of the test app.



  • I've know just added all libraries from the lib folder, without knowing wich one i need, since it was extremely painful to track down the correct libs.
    I somehow can't really believe this is so complicated to link those libs especially there isn't really a tutorial/list for which libs are required for a simple qt app, or is just much easier with qmake instead of cmake?

    anyway it works now.


Log in to reply