前言
在Linux下进行Qt开发时,习惯性的分了几个模块(1个主工程,3个共享动态库),编译通过了但运行时遇到了问题,虽然二进制可执行文件和动态库在同一目录下,但是就是提示找不到对应的动态库,在一番尝试后,需要用rpath来执行最高优先搜索动态库的路径就行
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| QT += widgets core gui
TEMPLATE = app CONFIG += c++17
CONFIG(release, debug|release): { DESTDIR = $$PWD/../Bin/Release LIBS += $$PWD/../Bin/Release/libUIElement.so LIBS += $$PWD/../Bin/Release/libPublicData.so LIBS += $$PWD/../Bin/Release/libAIModule.so } else: CONFIG(debug, debug|release): { DESTDIR = $$PWD/../Bin/Debug LIBS += $$PWD/../Bin/Debug/libUIElement.so LIBS += $$PWD/../Bin/Debug/libPublicData.so LIBS += $$PWD/../Bin/Debug/libAIModule.so }
#这句一定要放在上边逻辑的后边,因为上边重新指定了DESTDIR的路径 QMAKE_RPATHDIR += $$DESTDIR
HEADERS = \ mainwindow.h \
SOURCES = \ main.cpp \ mainwindow.cpp
RESOURCES += textedit.qrc
FORMS += \ finddialog.ui
|