PDA

View Full Version : Errors when linkink with static Qt lib



Scope
9th May 2016, 18:10
Hello guys,

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



./configure -opensource -static -release -qt-sql-sqlite -nomake examples -nomake tests -prefix /home/c50/Qt-source/qt-everywhere-opensource-src-5.6.0/staticlib


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:


18:52:48: Running steps for project MetaData...
18:52:48: Configuration unchanged, skipping qmake step.
18:52:48: Starting: "/usr/bin/make"
/home/c50/Qt5.6.0/5.6/gcc_64/bin/qmake -spec linux-g++ -o Makefile ../MetaData/MetaData.pro
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
/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)':
qregularexpression.cpp:(.text+0x1f9): undefined reference to `pcre16_exec'
qregularexpression.cpp:(.text+0x25d): undefined reference to `pcre16_jit_stack_alloc'
/home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::~QRegularExpressionPri vate()':
qregularexpression.cpp:(.text+0x453): undefined reference to `pcre16_free'
qregularexpression.cpp:(.text+0x466): undefined reference to `pcre16_free_study'
/home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::optimizePattern(QRegul arExpressionPrivate::OptimizePatternOption)':
qregularexpression.cpp:(.text+0xac9): undefined reference to `pcre16_study'
qregularexpression.cpp:(.text+0xaeb): undefined reference to `pcre16_assign_jit_stack'
/home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpressionPrivate::captureIndexForName(QS tring const&) const':
qregularexpression.cpp:(.text+0xbfb): undefined reference to `pcre16_get_stringnumber'
/home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function `QRegularExpression::~QRegularExpression()':
qregularexpression.cpp:(.text+0xe12): undefined reference to `pcre16_free'
qregularexpression.cpp:(.text+0xe21): undefined reference to `pcre16_free_study'
/home/c50/Qt-source/staticlib//libQt5Core.a(qregularexpression.o): In function`QRegularExpression::setPatternOptions(QFl ags<QRegularExpression::PatternOption>)':

collect2: error: ld returned 1 exit status
make: *** [MetaData] Error 1
18:52:48: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project MetaData (kit: Desktop Qt 5.6.0 GCC 64bit)
When executing step "Make"

my .pro file



QT += core
QT -= gui

TARGET = MetaData
CONFIG += console
CONFIG -= app_bundle
CONFIG += static
CONFIG += C++14

TEMPLATE = app

SOURCES += main.cpp

INCLUDEPATH += /home/c50/Qt-source/staticlib
LIBS += -L/home/c50/Qt-source/staticlib/ -lQt5Core


what can be wrong?

Regards,

d_stranz
9th May 2016, 19:24
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.

Scope
17th May 2016, 06:17
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


CONFIG += static

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?

11941