Results 1 to 3 of 3

Thread: Errors when linkink with static Qt lib

  1. #1
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Errors when linkink with static Qt lib

    Hello guys,

    I downloaded source code and built Qt 5.6 as static library by command

    Qt Code:
    1. ./configure -opensource -static -release -qt-sql-sqlite -nomake examples -nomake tests -prefix /home/c50/Qt-source/qt-everywhere-opensource-src-5.6.0/staticlib
    To copy to clipboard, switch view to plain text mode 

    everything went well and I have a lot of *.a lib files, for example libQt5Core.a etc.
    Now I created simple console application with one qDebug() statement and trying to compile it but i get a lot of errors:

    Qt Code:
    1. 18:52:48: Running steps for project MetaData...
    2. 18:52:48: Configuration unchanged, skipping qmake step.
    3. 18:52:48: Starting: "/usr/bin/make"
    4. /home/c50/Qt5.6.0/5.6/gcc_64/bin/qmake -spec linux-g++ -o Makefile ../MetaData/MetaData.pro
    5. g++ -Wl,-O1 -Wl,-z,origin -Wl,-rpath,\$ORIGIN -o MetaData main.o -L/home/c50/Qt-source/staticlib/ -L/home/c50/Qt5.6.0/5.6/gcc_64/lib -lQt5Core -lpthread
    6. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `pcre16SafeExec(real_pcre16 const*, pcre16_extra const*, unsigned short const*, int, int, int, int*, int)':
    7. qregularexpression.cpp:(.text+0x1f9): undefined reference to `pcre16_exec'
    8. qregularexpression.cpp:(.text+0x25d): undefined reference to `pcre16_jit_stack_alloc'
    9. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::~QRegularExpressionPrivate()':
    10. qregularexpression.cpp:(.text+0x453): undefined reference to `pcre16_free'
    11. qregularexpression.cpp:(.text+0x466): undefined reference to `pcre16_free_study'
    12. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::optimizePattern(QRegularExpressionPrivate::OptimizePatternOption)':
    13. qregularexpression.cpp:(.text+0xac9): undefined reference to `pcre16_study'
    14. qregularexpression.cpp:(.text+0xaeb): undefined reference to `pcre16_assign_jit_stack'
    15. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::captureIndexForName(QString const&) const':
    16. qregularexpression.cpp:(.text+0xbfb): undefined reference to `pcre16_get_stringnumber'
    17. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpression::~QRegularExpression()':
    18. qregularexpression.cpp:(.text+0xe12): undefined reference to `pcre16_free'
    19. qregularexpression.cpp:(.text+0xe21): undefined reference to `pcre16_free_study'
    20. /home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function`QRegularExpression::setPatternOptions(QFlags<QRegularExpression::PatternOption>)':
    21.  
    22. collect2: error: ld returned 1 exit status
    23. make: *** [MetaData] Error 1
    24. 18:52:48: The process "/usr/bin/make" exited with code 2.
    25. Error while building/deploying project MetaData (kit: Desktop Qt 5.6.0 GCC 64bit)
    26. When executing step "Make"
    To copy to clipboard, switch view to plain text mode 

    my .pro file

    Qt Code:
    1. QT += core
    2. QT -= gui
    3.  
    4. TARGET = MetaData
    5. CONFIG += console
    6. CONFIG -= app_bundle
    7. CONFIG += static
    8. CONFIG += C++14
    9.  
    10. TEMPLATE = app
    11.  
    12. SOURCES += main.cpp
    13.  
    14. INCLUDEPATH += /home/c50/Qt-source/staticlib
    15. LIBS += -L/home/c50/Qt-source/staticlib/ -lQt5Core
    To copy to clipboard, switch view to plain text mode 

    what can be wrong?

    Regards,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,324
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Errors when linkink with static Qt lib

    As the linker is telling you, you are missing the "pcre" library. Qt's regular expression classes depend on this. It looks like you are building on a linux platform, so I can't tell you where this library might be found. Maybe it is in your Qt distribution, maybe you need to install it. In any case, the path and library need to be added to the LIBS line in your .pro file.

  3. #3
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Errors when linkink with static Qt lib

    It is possible, that I gets all the above errors because I use incorrect ( non static ) version of qmake?

    I ask because when I create properly toolkit ( with static qmake ) then I only need add one line to .pro file

    Qt Code:
    1. CONFIG += static
    To copy to clipboard, switch view to plain text mode 

    and all works great.

    I see only one error ( see on screenshot )
    "Non-installed-prefix build - for interal development only" - what does it mean for me? I build Qt for static usage wrong?

    toolkit.jpg

Similar Threads

  1. Replies: 2
    Last Post: 19th December 2014, 09:47
  2. Replies: 1
    Last Post: 15th January 2014, 08:14
  3. Replies: 1
    Last Post: 29th June 2013, 16:23
  4. Static Qt+Webkit 4.6.2 Link Errors
    By geekox86 in forum Installation and Deployment
    Replies: 3
    Last Post: 20th June 2010, 05:06
  5. Qt 4.1.0 - static examples run with errors!
    By Elder Orb in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2006, 09:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.