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

Undefined references in Qt5.14.0 static using CMake (mingw) in Windows



  • I static compiled Qt5.14.0 with the MinGW compiler in windows using the following guide:

    https://amin-ahmadi.com/2017/11/01/how-to-build-qt-5-9-2-static-using-mingw/?unapproved=66401&moderation-hash=dd8787766bd2c5c39babd9aafe4255b7#comment-66401

    After compiling qt, projects created with qmake are static compiled without any errors. But projects defined as cmake give the following errors:

    qcoreapplication_win.cpp:-1: error: undefined reference to `GetFileVersionInfoSizeW@8'
    
    qcoreapplication_win.cpp:-1: error: undefined reference to `GetFileVersionInfoW@16'
    
    qcoreapplication_win.cpp:-1: error: undefined reference to `VerQueryValueW@16'
    
    qglobal.cpp:-1: error: undefined reference to `_imp__WSACleanup@0'
    
    qglobal.cpp:-1: error: undefined reference to `_imp__WSAStartup@8'
    
    qglobal.cpp:-1: error: undefined reference to `_imp__WSACleanup@0'
    

    CMakeLists.txt file

    cmake_minimum_required(VERSION 3.5)
    
    project(untitled27 LANGUAGES CXX)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt5Core)
    
    add_executable(untitled27
      main.cpp
    )
    target_link_libraries(untitled27 Qt5::Core)
    

    main.cpp file

    #include <QCoreApplication>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        return a.exec();
    }
    

  • Lifetime Qt Champion

    When you use GetFileVersionInfoW you need to link against version.lib according the msdn documentation.



  • @Christian-Ehrlicher
    hi
    the error are much more:
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qcoreapplication_win.o):qcoreapplication_win.cpp:(.text$_ZNK23QCoreApplicationPrivate10appVersionEv+0x9d): undefined reference to GetFileVersionInfoSizeW@8' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qcoreapplication_win.o):qcoreapplication_win.cpp:(.text$_ZNK23QCoreApplicationPrivate10appVersionEv+0xf1): undefined reference toGetFileVersionInfoW@16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qcoreapplication_win.o):qcoreapplication_win.cpp:(.text$_ZNK23QCoreApplicationPrivate10appVersionEv+0x200): undefined reference to VerQueryValueW@16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qglobal.o):qglobal.cpp:(.text$__tcf_0+0x5): undefined reference to_imp__WSACleanup@0'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qglobal.o):qglobal.cpp:(.text$_ZN16QWindowsSockInitC2Ev+0x20): undefined reference to _imp__WSAStartup@8' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qglobal.o):qglobal.cpp:(.text$_ZN16QWindowsSockInitD2Ev+0x2): undefined reference to_imp__WSACleanup@0'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qglobal.o):qglobal.cpp:(.text$_ZN8QSysInfo15machineHostNameEv+0x40): undefined reference to _imp__gethostname@8' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qglobal.o):qglobal.cpp:(.text$_ZN8QSysInfo15machineHostNameEv+0xdb): undefined reference to_imp__WSAStartup@8'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qbytearray.o):qbytearray.cpp:(.text$_Z11qUncompressPKhi+0x83): undefined reference to uncompress' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qbytearray.o):qbytearray.cpp:(.text$_Z9qCompressPKhii+0xb0): undefined reference tocompress2'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN14QThreadStorageIP20QPcreJitStackPointerE10deleteDataEPv[__ZN14QThreadStorageIP20QPcreJitStackPointerE10deleteDataEPv]+0x16): undefined reference to pcre2_jit_stack_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZL19safe_pcre2_match_16PK18pcre2_real_code_16PKtiiiP24pcre2_real_match_data_16P27pcre2_real_match_context_16+0x38): undefined reference topcre2_match_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZL19safe_pcre2_match_16PK18pcre2_real_code_16PKtiiiP24pcre2_real_match_data_16P27pcre2_real_match_context_16+0xa1): undefined reference to pcre2_jit_stack_create_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZL19safe_pcre2_match_16PK18pcre2_real_code_16PKtiiiP24pcre2_real_match_data_16P27pcre2_real_match_context_16+0xff): undefined reference topcre2_match_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivateD2Ev+0xd): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate20cleanCompiledPatternEv+0xd): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14getPatternInfoEv+0x21): undefined reference to pcre2_pattern_info_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14getPatternInfoEv+0x38): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14getPatternInfoEv+0x65): undefined reference to pcre2_pattern_info_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14getPatternInfoEv+0x8c): undefined reference topcre2_config_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate15optimizePatternEv+0x2f): undefined reference to pcre2_jit_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14compilePatternEv+0x3b): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN25QRegularExpressionPrivate14compilePatternEv+0xf3): undefined reference to pcre2_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate19captureIndexForNameE11QStringView+0x16): undefined reference topcre2_substring_number_from_name_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QRegularExpressionD2Ev+0x1d): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QRegularExpressionaSERKS_+0x3c): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QRegularExpression10setPatternERK7QString+0x96): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QRegularExpression17setPatternOptionsE6QFlagsINS_13PatternOptionEE+0x91): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression12captureCountEv+0x4b): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression12captureCountEv+0x10b): undefined reference topcre2_compile_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression7isValidEv+0x4b): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression7isValidEv+0x10b): undefined reference topcre2_compile_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression11errorStringEv+0x95): undefined reference to pcre2_get_error_message_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression18patternErrorOffsetEv+0x3d): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression18patternErrorOffsetEv+0xfd): undefined reference to pcre2_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression8optimizeEv+0x3b): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression8optimizeEv+0xf3): undefined reference to pcre2_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN23QRegularExpressionMatchD2Ev+0x77): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$ZN23QRegularExpressionMatchaSERKS+0x97): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch8capturedERK7QString+0x30): undefined reference topcre2_substring_number_from_name_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch11capturedRefERK7QString+0x34): undefined reference to pcre2_substring_number_from_name_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch8capturedE11QStringView+0x2c): undefined reference topcre2_substring_number_from_name_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch11capturedRefE11QStringView+0x2c): undefined reference to pcre2_substring_number_from_name_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch12capturedViewE11QStringView+0x2b): undefined reference topcre2_substring_number_from_name_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK23QRegularExpressionMatch13capturedStartERK7QString+0x2c): more undefined references to pcre2_substring_number_from_name_16' follow C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN31QRegularExpressionMatchIteratorD2Ev+0x3f): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN31QRegularExpressionMatchIteratorD2Ev+0x113): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN31QRegularExpressionMatchIteratoraSERKS_+0x58): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$ZN31QRegularExpressionMatchIteratoraSERKS+0x13b): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZrsR11QDataStreamR18QRegularExpression+0xc1): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZrsR11QDataStreamR18QRegularExpression+0x1c9): more undefined references to pcre2_code_free_16' follow C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x1ce): undefined reference topcre2_match_context_create_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x1e9): undefined reference to pcre2_jit_stack_assign_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x1ff): undefined reference topcre2_match_data_create_from_pattern_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x421): undefined reference to pcre2_get_ovector_pointer_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x4a1): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x4b7): undefined reference to pcre2_match_data_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x4c2): undefined reference topcre2_match_context_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK25QRegularExpressionPrivate7doMatchERK7QStringiiiN18QRegularExpression9MatchTypeE6QFlagsINS3_11MatchOptionEENS_24CheckSubjectStringOptionEPK30QRegularExpressionMatchPrivate+0x4e1): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression11globalMatchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x13b): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression11globalMatchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x1c0): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression11globalMatchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x280): undefined reference topcre2_compile_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression11globalMatchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x158): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x183): undefined reference topcre2_match_context_create_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x19e): undefined reference to pcre2_jit_stack_assign_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x1b4): undefined reference topcre2_match_data_create_from_pattern_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x3cd): undefined reference to pcre2_get_ovector_pointer_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x454): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x467): undefined reference to pcre2_match_data_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x472): undefined reference topcre2_match_context_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x491): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x50b): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK7QStringiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x5bb): undefined reference to pcre2_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x1bd): undefined reference topcre2_match_context_create_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x1de): undefined reference to pcre2_jit_stack_assign_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x1fa): undefined reference topcre2_match_data_create_from_pattern_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x411): undefined reference to pcre2_get_ovector_pointer_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x492): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x4a7): undefined reference to pcre2_match_data_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x4b2): undefined reference topcre2_match_context_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x4d1): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x59c): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression5matchERK10QStringRefiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE+0x64c): undefined reference to pcre2_compile_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x137): undefined reference topcre2_match_context_create_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x152): undefined reference to pcre2_jit_stack_assign_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x168): undefined reference topcre2_match_data_create_from_pattern_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x38e): undefined reference to pcre2_get_ovector_pointer_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x410): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x427): undefined reference to pcre2_match_data_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x432): undefined reference topcre2_match_context_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK30QRegularExpressionMatchPrivate9nextMatchEv+0x451): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression18namedCaptureGroupsEv+0x38): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression18namedCaptureGroupsEv+0x54): undefined reference to pcre2_pattern_info_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZNK18QRegularExpression18namedCaptureGroupsEv+0x70): undefined reference topcre2_pattern_info_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QSharedDataPointerI38QRegularExpressionMatchIteratorPrivateE6detachEv[__ZN18QSharedDataPointerI38QRegularExpressionMatchIteratorPrivateE6detachEv]+0x91): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QSharedDataPointerI38QRegularExpressionMatchIteratorPrivateE6detachEv[__ZN18QSharedDataPointerI38QRegularExpressionMatchIteratorPrivateE6detachEv]+0x16b): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN18QSharedDataPointerI30QRegularExpressionMatchPrivateE13detach_helperEv[__ZN18QSharedDataPointerI30QRegularExpressionMatchPrivateE13detach_helperEv]+0xfd): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN23QRegularExpressionMatchC2Ev+0x112): undefined reference topcre2_code_free_16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN31QRegularExpressionMatchIteratorC2Ev+0x11c): undefined reference to pcre2_code_free_16' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qregularexpression.o):qregularexpression.cpp:(.text$_ZN31QRegularExpressionMatchIteratorC2Ev+0x1a1): more undefined references topcre2_code_free_16' follow
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qfilesystemengine_win.o):qfilesystemengine_win.cpp:(.text$_ZN17QFileSystemEngine8homePathEv+0x547): undefined reference to _imp__GetUserProfileDirectoryW@12' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qfilesystemengine_win.o):qfilesystemengine_win.cpp:(.text$_ZN17QFileSystemEngine21uncListSharesOnServerERK7QStringP11QStringList+0x2e): undefined reference toNetApiBufferFree@4'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qfilesystemengine_win.o):qfilesystemengine_win.cpp:(.text$_ZN17QFileSystemEngine21uncListSharesOnServerERK7QStringP11QStringList+0x7a): undefined reference to NetShareEnum@28' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN28QEventDispatcherWin32Private13registerTimerEP12WinTimerInfo+0x167): undefined reference to_imp__timeSetEvent@20'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN28QEventDispatcherWin32Private15unregisterTimerEP12WinTimerInfo+0x37): undefined reference to _imp__timeKillEvent@4' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN28QEventDispatcherWin32Private16doWsaAsyncSelectEil+0x29): undefined reference to_imp__WSAAsyncSelect@16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3218createInternalHwndEv+0x294): undefined reference to _imp__timeSetEvent@20' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3222registerSocketNotifierEP15QSocketNotifier+0x4e0): undefined reference to_imp__WSAAsyncSelect@16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3215unregisterTimerEi+0x125): undefined reference to _imp__timeKillEvent@4' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3216unregisterTimersEP7QObject+0x1e5): undefined reference to_imp__timeKillEvent@4'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3212internalHwndEv+0x294): undefined reference to _imp__timeSetEvent@20' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3226doUnregisterSocketNotifierEP15QSocketNotifier+0x362): undefined reference to_imp__WSAAsyncSelect@16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_ZN21QEventDispatcherWin3211closingDownEv+0x349): undefined reference to _imp__timeKillEvent@4' C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_Z16qt_internal_procP6HWND__jjl+0x3d2): undefined reference to_imp__WSAAsyncSelect@16'
    C:/Qt/Qt5.14.0/5.14.0/mingw73_32_static/lib/libQt5Core.a(qeventdispatcher_win.o):qeventdispatcher_win.cpp:(.text$_Z16qt_internal_procP6HWND__jjl+0x58e): undefined reference to `_imp__WSAAsyncSelect@16'


  • Lifetime Qt Champion

    I already provided you a link to the msdn. Search the missing functions there and add the appropriate libs.



  • I searched for this problem a lot and found the problem in the link below, which is related to a bug in version Qt5.14.0 that has been fixed in higher versions.
    I tested with version Qt5.14.2 and it was compiled without error.
    https://stackoverflow.com/questions/41765673/static-linking-against-qt-on-windows-using-cmake

    https://codereview.qt-project.org/c/qt/qtbase/+/282408


Log in to reply