Unsolved Qt 5.12 and static build.
-
I have simple console application with qt core,
I used to build a project with qt 5.11 and everything was fine, but when it was over 5.12, the following problem appeared:I build qt as follows:
./configure -confirm-license -prefix $BASE_DIR/$QT_DIR -release -optimize-size -static -no-opengl -no-openssl -opensource -nomake tests -nomake examples -no-gui -no-widgets -no-dbus -no-accessibility
qt is successfully built, but when I build my application with the static flag, it starts to require dynamic libraries (although this should not be, and everything was fine with qt 5.11) and is not going to happen because of this.
export PATH=$PATH:$BASE_DIR/$QT_DIR $BASE_DIR/$QT_DIR/bin/qmake -r QMAKE_LFLAGS+="-static -static-libgcc -static-libstdc++" $BASE_DIR/CQtDeployer.pro
Here is the build error:
g++ -static -static-libgcc -static-libstdc++ -Wl,-O1 -Wl,--gc-sections -o build/release/cqtdeployer main.o -L/media/D/own/Console-QtDeployer/QuasarAppLib/build/release -lQuasarApp -L/media/D/own/Console-QtDeployer/Deploy/build/release -lDeploy -L/media/D/own/Console-QtDeployer/pe/pe-parser-library/build/release -lpe-parser-library -L/media/D/own/Console-QtDeployer/staticQt/lib -lQt5Core -lm /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libpcre2-16.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libgthread-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -lpthread /usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so' collect2: error: ld returned 1 exit status Makefile:116: recipe for target 'build/release/cqtdeployer' failed make[1]: *** [build/release/cqtdeployer] Error 1 make[1]: выход из каталога «/media/D/own/Console-QtDeployer/CQtDeployer» Makefile:178: recipe for target 'sub-CQtDeployer-make_first-ordered' failed make: *** [sub-CQtDeployer-make_first-ordered] Error 2
-
Use built-in libz when building Qt:
-zlib ................ Select used zlib [system/qt]
-
Thanks, it helped me, but now it requires a different library, is it possible to customize qt in some way so that by default it will always choose its own library build, if possible?
now :
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libpcre2-16.so'
-
No, each external lib has to be configured separately. See output of
configure --help
. -
Thanks for the help
-
This post is deleted! -
@sierdzio
Still such question why at static assembly dynamic still can be required?g++ -static -Wl,-O1 -Wl,--gc-sections -o build/release/cqtdeployer main.o -L/media/D/own/Console-QtDeployer/QuasarAppLib/build/release -lQuasarApp -L/media/D/own/Console-QtDeployer/Deploy/build/release -lDeploy -L/media/D/own/Console-QtDeployer/pe/pe-parser-library/build/release -lpe-parser-library -L/media/D/own/Console-QtDeployer/staticQt/lib -lQt5Core -lm /media/D/own/Console-QtDeployer/staticQt/lib/libqtpcre2.a /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libgthread-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -lpthread /usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libdl.so' collect2: error: ld returned 1 exit status Makefile:117: recipe for target 'build/release/cqtdeployer' failed make[1]: *** [build/release/cqtdeployer] Error 1 make[1]: выход из каталога «/media/D/own/Console-QtDeployer/CQtDeployer» Makefile:178: recipe for target 'sub-CQtDeployer-make_first-ordered' failed make: *** [sub-CQtDeployer-make_first-ordered] Error 2
-
No idea. Perhaps you should pass
-static-libgcc -static-libstdc++
to Qt compilation as well. Because your code will use static runtime, but Qt still expects dynamic one. -
@sierdzio
did not help (
I reopen this issue. -
This is more like a qmake bug.
The fact is that I changed the list of libraries necessary for linking in my makefile toLIBS = $(SUBLIBS) -L/media/D/own/Console-QtDeployer/QuasarAppLib/build/release -lQuasarApp -L/media/D/own/Console-QtDeployer/Deploy/build/release -lDeploy -L/media/D/own/Console-QtDeployer/pe/pe-parser-library/build/release -lpe-parser-library -L/media/D/own/Console-QtDeployer/staticQt/lib -lQt5Core -lm /media/D/own/Console-QtDeployer/staticQt/lib/libqtpcre2.a -ldl -lglib-2.0 -lpthread
and it all worked, I got the right binary.
before editing was:
CC = gcc CXX = g++ DEFINES = -DWITHOUT_BASE_TESTS -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB CFLAGS = -pipe -O2 -Wall -W -ffunction-sections -fdata-sections -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -O2 -std=gnu++1y -Wall -W -ffunction-sections -fdata-sections -D_REENTRANT -fPIC $(DEFINES) INCPATH = -I. -I../QuasarAppLib -I../Deploy -I../pe/pe-parser-library/include -I../staticQt/include -I../staticQt/include/QtCore -I. -I../staticQt/mkspecs/linux-g++ QMAKE = /media/D/own/Console-QtDeployer/staticQt/bin/qmake DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p COPY = cp -f COPY_FILE = cp -f COPY_DIR = cp -f -R INSTALL_FILE = install -m 644 -p INSTALL_PROGRAM = install -m 755 -p INSTALL_DIR = cp -f -R QINSTALL = /media/D/own/Console-QtDeployer/staticQt/bin/qmake -install qinstall QINSTALL_PROGRAM = /media/D/own/Console-QtDeployer/staticQt/bin/qmake -install qinstall -exe DEL_FILE = rm -f SYMLINK = ln -f -s DEL_DIR = rmdir MOVE = mv -f TAR = tar -cf COMPRESS = gzip -9f DISTNAME = cqtdeployer1.0.0 DISTDIR = /media/D/own/Console-QtDeployer/CQtDeployer/.tmp/cqtdeployer1.0.0 LINK = g++ LFLAGS = -static -static-libgcc -static-libstdc++ -Wl,-O1 -Wl,--gc-sections LIBS = $(SUBLIBS) -L/media/D/own/Console-QtDeployer/QuasarAppLib/build/release -lQuasarApp -L/media/D/own/Console-QtDeployer/Deploy/build/release -lDeploy -L/media/D/own/Console-QtDeployer/pe/pe-parser-library/build/release -lpe-parser-library -L/media/D/own/Console-QtDeployer/staticQt/lib -lQt5Core -lm /media/D/own/Console-QtDeployer/staticQt/lib/libqtpcre2.a /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libgthread-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -lpthread AR = ar cqs RANLIB = SED = sed STRIP = strip
my pro file:
# # Copyright (C) 2018-2019 QuasarApp. # Distributed under the lgplv3 software license, see the accompanying # Everyone is permitted to copy and distribute verbatim copies # of this license document, but changing it is not allowed. # QT -= gui CONFIG += c++14 console CONFIG -= app_bundle # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG(release, debug|release): { DESTDIR="$$PWD/build/release" } else { DESTDIR="$$PWD/build/debug" } include('$$PWD/../QuasarAppLib/QuasarLib.pri') include('$$PWD/../Deploy/Deploy.pri') include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri') TARGET = cqtdeployer SOURCES += \ main.cpp \ win32: RC_ICONS = $$PWD/../res/icon.ico
maybe you need to configure qmake in some special way?