我正在关注这个example这里。 这是我为 make 得到的输出
admin@localhost qtest$ make
g++ -Wl,-O1 -Wl,-rpath,/home/admin/Qt/5.3/gcc_64 -Wl,-rpath,/home/admin/Qt/5.3/gcc_64/lib -o qtest qtest.o -L/home/admin/Qt/5.3/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [qtest] Error 1
admin@localhost qtest$
我的cpp文件是这样的
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qpushbutton.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
hello.show();
return a.exec();
}
关于如何解决这个问题有什么建议吗?
更新
这就是我想要的
sudo yum install mesa-libGL-devel -y
再次尝试构建:
admin@localhost qtest$ make
g++ -Wl,-O1 -Wl,-rpath,/home/admin/Qt/5.3/gcc_64 -Wl,-rpath,/home/admin/Qt/5.3/gcc_64/lib -o qtest qtest.o -L/home/admin/Qt/5.3/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread
qtest.o: In function `main':
qtest.cpp:(.text.startup+0x22): undefined reference to `QApplication::QApplication(int&, char**, int)'
qtest.cpp:(.text.startup+0x4f): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
qtest.cpp:(.text.startup+0x74): undefined reference to `QWidget::resize(QSize const&)'
qtest.cpp:(.text.startup+0x7c): undefined reference to `QWidget::show()'
qtest.cpp:(.text.startup+0x81): undefined reference to `QApplication::exec()'
qtest.cpp:(.text.startup+0x8c): undefined reference to `QPushButton::~QPushButton()'
qtest.cpp:(.text.startup+0x94): undefined reference to `QApplication::~QApplication()'
qtest.cpp:(.text.startup+0xab): undefined reference to `QApplication::~QApplication()'
qtest.cpp:(.text.startup+0xbe): undefined reference to `QPushButton::~QPushButton()'
qtest.cpp:(.text.startup+0xce): undefined reference to `QPushButton::~QPushButton()'
collect2: error: ld returned 1 exit status
make: *** [qtest] Error 1
最佳答案
解决您的错误:
/usr/bin/ld: cannot find -lGL
您应该以 root 身份运行以下安装命令或使用 sudo
来安装缺少的 mesa 包:
sudo yum install mesa-libGL-devel -y
关于c++ - 在 fedora 20 上使 Qt 应用程序失败 :/usr/bin/ld: cannot find -lGL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26965620/