如何在qt静态构建中构建动态库

时间:2017-11-21 08:19:06

标签: linux qt qt-creator dynamic-library

我尝试在linux中构建我的动态库项目。我在静态中构建我的qt库。但如果我使用它来构建我的proj,qt creator只构建libname.a文件。但是,如果我使用原始qt库qt creator构建libname.so文件。 Wats是问题吗? 专业档案。

`#------------------------------------------------- # # 
Project created by QtCreator 2020-10-22T07:46:59 
# #------------------------------------------------- 
QT -= gui TARGET = up_api_send 
TEMPLATE = lib 
DEFINES += UP_API_SEND_LIBRARY 
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += up_api_send.cpp 
HEADERS += up_api_send.h\ 
           up_api_send_global.h 
unix { target.path = /usr/lib INSTALLS += target } 
unix:!macx: LIBS += -L$$PWD/libplot/ -lplot2 
INCLUDEPATH += $$PWD/headerplot 
DEPENDPATH += $$PWD/headerplot`

构建日志。 原始图书馆。

16:04:07: Start build project up_api_send...
16:04:07: Starts: «/opt/Qt5.7.1/5.7/gcc_64/bin/qmake» /root/QT/QT_SO/up_api_send/up_api_send.pro -spec linux-g++
Info: creating stash file /root/QT/QT_SO/build-up_api_send-Desktop_Qt_5_7_1_GCC_64bit-Release/.qmake.stash
16:04:07: Процесс «/opt/Qt5.7.1/5.7/gcc_64/bin/qmake» success.
16:04:07: Starts: «/usr/bin/make» qmake_all
make: Target `qmake_all' action is not required.
16:04:07: Process «/usr/bin/make» success.
16:04:07: Starts: «/usr/bin/make» 
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -o up_api_send.o ../up_api_send/up_api_send.cpp
../up_api_send/up_api_send.cpp: In member function ‘bool DgateTrans::PLOT_sendMsg(const char*, const char*, int)’:
../up_api_send/up_api_send.cpp:143:19: warning: unused variable ‘tid’ [-Wunused-variable]
/opt/Qt5.7.1/5.7/gcc_64/bin/moc -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -I/root/QT/QT_SO/up_api_send -I/root/QT/QT_SO/up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/usr/include/c++/4.7 -I/usr/include/c++/4.7/x86_64-linux-gnu -I/usr/include/c++/4.7/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../up_api_send/up_api_send.h -o moc_up_api_send.cpp
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -o moc_up_api_send.o moc_up_api_send.cpp
rm -f libup_api_send.so.1.0.0 libup_api_send.so libup_api_send.so.1 libup_api_send.so.1.0
g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.7.1/5.7/gcc_64/lib -shared -Wl,-soname,libup_api_send.so.1 -o libup_api_send.so.1.0.0 up_api_send.o moc_up_api_send.o  -L/root/QT/QT_SO/up_api_send/libplot/ -lplot2 -L/opt/Qt5.7.1/5.7/gcc_64/lib -lQt5Core -lpthread  
ln -s libup_api_send.so.1.0.0 libup_api_send.so
ln -s libup_api_send.so.1.0.0 libup_api_send.so.1
ln -s libup_api_send.so.1.0.0 libup_api_send.so.1.0
16:04:09: Process «/usr/bin/make» success.
16:04:09: Time passed: 00:02.

构建日志。静态库。

 16:05:00: Start build project up_api_send...
16:05:00: Settings not changed, stage qmake is skipped.
16:05:00: Starts: «/usr/bin/make» 
g++ -c -pipe -O2 -fPIC -std=gnu++11 -Wall -W -D_REENTRANT -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -o up_api_send.o ../up_api_send/up_api_send.cpp
../up_api_send/up_api_send.cpp: In member function ‘bool DgateTrans::PLOT_sendMsg(const char*, const char*, int)’:
../up_api_send/up_api_send.cpp:143:19: warning: unused variable ‘tid’ [-Wunused-variable]
/usr/local/Qt-5.7.1/bin/moc -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -I/root/QT/QT_SO/up_api_send -I/root/QT/QT_SO/up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/include/c++/4.7 -I/usr/include/c++/4.7/x86_64-linux-gnu -I/usr/include/c++/4.7/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../up_api_send/up_api_send.h -o moc_up_api_send.cpp
g++ -c -pipe -O2 -fPIC -std=gnu++11 -Wall -W -D_REENTRANT -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -o moc_up_api_send.o moc_up_api_send.cpp
rm -f libup_api_send.a
ar cqs libup_api_send.a up_api_send.o moc_up_api_send.o
16:05:02: Process «/usr/bin/make» success.
16:05:02: Time passed: 00:02.

也许我在构建qt库时写了错误的参数?

./configure -platform linux-g++ 
-release  
-static  
-fontconfig  
-opensource  
-confirm-license 
-gtkstyle 
-no-webkit
-nomake demos
-nomake examples

0 个答案:

没有答案