gpt4 book ai didi

linux - 获取静态链接Qt5的XCB插件的加载库或链接错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:10:10 25 4
gpt4 key购买 nike

尝试创建 C++ Qt5.6.1 应用程序并在 Debian 上启动它。获取链接错误或加载库错误。

Qt 构建到静态库,使用的配置

configure -release -confirm-license -opensource -static -no-dbus -no-openssl -no-qml-debug -no-opengl -qt-freetype -qt-xcb -nomake tools -nomake tests -nomake examples -no-sql-db2 -no-sql-oci -no-sql-tds -no-sql-sqlite2 -no-sql-odbc -no-sql-ibase -no-sql-psql -skip doc -skip imageformats -skip webchannel -skip webengine -skip webview -skip sensors -skip serialport -skip script -skip multimedia

使用 Cmake 创建的项目,库是这样指定的:

SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${QT5_LIB_ROOT}/cmake")

FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)

FIND_PACKAGE( PNG REQUIRED )
FIND_PACKAGE( ZLIB REQUIRED)
FIND_PACKAGE( Threads REQUIRED )

IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(QT_LIBS
libqtharfbuzzng_debug.a
libqtpcre_debug.a
libQt5PlatformSupport_debug.a
libxcb-static_debug.a
)
ELSE()
SET(QT_LIBS
libqtharfbuzzng.a
libqtpcre.a
libQt5PlatformSupport.a
libxcb-static.a
)
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")

SET(OS_SPECIFIC_LIBS
dl
Qt5::QXcbIntegrationPlugin
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARIES}
${PNG_LIBRARY} )

FOREACH(lib_name ${QT_LIBS})
IF(NOT EXISTS ${QT5_LIB_ROOT}/${lib_name})
MESSAGE(FATAL_ERROR "Could not locate required Qt lib ${QT5_LIB_ROOT}/${lib_name}")
ENDIF()

LIST(APPEND OS_SPECIFIC_LIBS ${QT5_LIB_ROOT}/${lib_name})
ENDFOREACH(lib_name)

如果我在代码中导入 XCB 插件 ( Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) 它会给我链接错误:

    /Qt5/plugins/platforms/libqxcb.a(qxcbmain.o): In function `QXcbIntegrationPlugin::create(QString const&, QStringList const&, int&, char**)':
qxcbmain.cpp:(.text+0x67): undefined reference to `QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**)'

Anf 如果我不导入插件 - 它不会以错误开头:

This application failed to start because it could not find or load the Qt platform plugin "xcb"

有什么帮助吗?建议?

谢谢。

最佳答案

解决方案很简单——只需链接适当的系统库:添加固定

FIND_PACKAGE( X11 REQUIRED )

SET(OS_SPECIFIC_LIBS
...
xcb
X11-xcb
${X11_LIBRARIES}
)

关于linux - 获取静态链接Qt5的XCB插件的加载库或链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38531654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com