【发布时间】:2018-02-25 22:58:52
【问题描述】:
我尝试用 CentOS 编译 Qt 项目。 This 问题详细描述了我所做的事情和 我想通过引用this 来处理另一个glibc 库/users/my/lib64/(我无法更新/lib64/)。
这是编译输出:
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 `clock_gettime@GLIBC_2.17'
/users/my/Qt/5.9.1/gcc_64/lib/libQt5Widgets.so: undefined reference to `memcpy@GLIBC_2.14'
collect2 ld returned exit 1 status
如何解决?
【问题讨论】:
-
将您的
.pro文件添加到问题中,似乎是链接错误并包含您的 gcc 版本 -
我很困惑你是想在本地机器上编译你的项目并将其部署到目标机器上还是你想在目标机器上编译项目
-
谢谢。我修改我的问题。很抱歉,前者是理想的,但我无法在目标机器上运行应用程序,所以我尝试后者。
-
创建一个简单的项目并构建。我想检查您是否可以只构建一个简单的应用程序?
-
我做了一个简单的项目,只有关闭按钮,但是我使用Qtcreator并拿起发布项目,所以我对用cui构建不太了解。
标签: qt centos linker-errors glibc undefined-reference