我嘗試用CentOS編譯Qt項目。 This問題描述我所做的細節和 我想通過參考this與另一個glibc庫/users/my/lib64/(我無法更新/ lib64 /)。編譯:未定義的參考「clock_gettime和memcpy」用於Qt項目
這是編出來的說:
g++ ./main.o ./moc_widget.o ./widget.o \
-o ./test -Wl,--rpath=/users/my/lib64 \
-Wl,--rpath=/users/my/Qt/5.9.1/gcc_64/lib \
-Wl,--dynamic-linker=/users/my/lib64/libc.so.6 \
-Wl,--dynamic-linker=/users/my/lib64/libz.so.1 \
-L/users/my/Qt/5.9.1/gcc_64/lib -lQt5Widgets \
-lQt5Gui -lQt5Core -lGL -lpthread -lglib-2.0 -lrt -lX11 \
-I/users/my/test/2 \
-I/users/my/Qt/5.9.1/gcc_64/include \
-I/users/my/Qt/5.9.1/gcc_64/include/QtWidgets \
-I/users/my/Qt/5.9.1/gcc_64/include/QtCore \
-I/users/my/Qt/5.9.1/gcc_64/include/QtGui
.pro文件:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += qt
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
FORMS += \
widget.ui
gcc版本:6.1.0
但錯誤:
/users/my/Qt/5.9.1/gcc_64/lib/libQt5Core.so: undefined reference to `[email protected]_2.17'
/users/my/Qt/5.9.1/gcc_64/lib/libQt5Widgets.so: undefined reference to `[email protected]_2.14'
collect2 ld returned exit 1 status
如何解決它?
將你的'.pro'文件添加到問題中,看起來是一個鏈接錯誤,幷包含你的gcc版本 – saeed
我很困惑你想在本地機器上編譯你的項目並將它部署到目標機器或者你想編譯項目目標machie – saeed
謝謝。我修改我的問題。對不起,前者是理想的,但我不能在目標機器上運行應用程序,所以我嘗試後者。 – yaa