[Interest] Static build of Qt - debug mode and plugins
Jakub Narolewski
izowiuz at gmail.com
Sun Aug 25 17:59:23 CEST 2019
Yea, it builds fine when I reorder them in my CMakeLists.
My ‘invalid’ CMakeLists part dealing with external libraries looks like this:
# global target link libraries
target_link_libraries(${TARGET_FULL_NAME}
PRIVATE
Qt5::Core
Qt5::Sql
Qt5::Network
Qt5::Concurrent
Qt5::WebSockets
${BOX2D_LIBRARY}
${LZ4_LIBRARY}
)
# on unix-based systems we use static qt build - add some stuff to target link libraries
if (LINUX)
target_link_libraries(${TARGET_FULL_NAME}
PRIVATE
Qt5::QPSQLDriverPlugin
Qt5::QSQLiteDriverPlugin
"libpq.so"
)
endif()
# small hack to properly set LZ4 library between build modes
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
(${TARGET_FULL_NAME} PRIVATE ${LZ4_LIBRARY_DEBUG})
else ()
target_link_libraries(${TARGET_FULL_NAME} PRIVATE ${LZ4_LIBRARY_RELEASE})
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
I don’t use any more target_link_libraries functions in there so I don’t know from where this extra libQt5Network come from.
Do you have any idea why it actually builds this way under Release mode?
>From what I see, order of the libraries are the same between Release and Debug and only Debug generates those errors.
// RELEASE
/usr/local/Qt-5.13.0/lib/libQt5Core.a
/usr/local/Qt-5.13.0/lib/libQt5Sql.a
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Concurrent.a
/usr/local/Qt-5.13.0/lib/libQt5WebSockets.a
/home/izowiuz/vcpkg/installed/x64-linux/lib/libBox2D.a
/usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlpsql.a
/usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlite.a
-lpq
/home/izowiuz/vcpkg/installed/x64-linux/lib/liblz4.a
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Core.a -lpthread
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Core.a -lm
/usr/local/Qt-5.13.0/lib/libqtpcre2.a -ldl -lssl -lcrypto
// DEBUG
/usr/local/Qt-5.13.0/lib/libQt5Core.a
/usr/local/Qt-5.13.0/lib/libQt5Sql.a
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Concurrent.a
/usr/local/Qt-5.13.0/lib/libQt5WebSockets.a
/home/izowiuz/vcpkg/installed/x64-linux/debug/lib/libBox2D.a
/usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlpsql.a
/usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlite.a
-lpq
/home/izowiuz/vcpkg/installed/x64-linux/debug/lib/liblz4d.a
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Core.a -lpthread
/usr/local/Qt-5.13.0/lib/libQt5Network.a
/usr/local/Qt-5.13.0/lib/libQt5Core.a -lm
/usr/local/Qt-5.13.0/lib/libqtpcre2.a -ldl -lssl -lcrypto
Narolewski Jakub
From: Thiago Macieira
Sent: 25 August 2019 17:46
To: interest at qt-project.org
Subject: Re: [Interest] Static build of Qt - debug mode and plugins
On Sunday, 25 August 2019 00:25:50 PDT Jakub Narolewski wrote:
> /usr/local/Qt-5.13.0/lib/libQt5Core.a
> /usr/local/Qt-5.13.0/lib/libQt5Sql.a
> /usr/local/Qt-5.13.0/lib/libQt5Network.a
> /usr/local/Qt-5.13.0/lib/libQt5Concurrent.a
> /usr/local/Qt-5.13.0/lib/libQt5WebSockets.a
> /home/izowiuz/vcpkg/installed/x64-linux/lib/libBox2D.a
> /usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlpsql.a
> /usr/local/Qt-5.13.0/plugins/sqldrivers/libqsqlite.a
> -lpq
> /home/izowiuz/vcpkg/installed/x64-linux/lib/liblz4.a
> /usr/local/Qt-5.13.0/lib/libQt5Network.a
> /usr/local/Qt-5.13.0/lib/libQt5Core.a -lpthread
> /usr/local/Qt-5.13.0/lib/libQt5Network.a
> /usr/local/Qt-5.13.0/lib/libQt5Core.a -lm
> /usr/local/Qt-5.13.0/lib/libqtpcre2.a -ldl -lssl -lcrypto
The order is wrong, as you can see. libQt5Sql.a appears before the plugins.
Invert the order and make the plugins appear before the library in this link
line.
It's interesting that the order is mostly correct. It seems that CMake is
applying dependency sorting correctly. If that is the case, then either it's a
CMake bug or there's some information missing in the qmake-generated CMake
files. Reporting a bug here is unlikely to get you enough attention, so you
may want to get your hands dirty and debug yourself.
It's also interesting that QtCore and QtNetwork are listed three times.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190825/1d4364bc/attachment.html>
More information about the Interest
mailing list