ubuntu运行qt项目出现error ld returned 1 exit status

关于ubuntu运行qt项目出现error ld returned 1 exit status这个问题

Ubuntu安装好Qt5.8.0后,通过helloworld项目测试环境是否OK时,
编译时出现
/usr/bin/ld: 找不到 -lGL
Makefile:236: recipe for target ‘untitled’ failed
collect2: error: ld returned 1 exit status
make: *** [untitled] Error 1
01:12:01: 进程"/usr/bin/make"退出,退出代码 2 。
Error while building/deploying project untitled (kit: Desktop Qt 5.8.0 GCC 64bit)
When executing step “Make”

linux下QT编译出现collect2:ld returned 1 exit status错误的原因之一是未安装mesa
解决方法
终端输入sudo apt install libgl1-mesa-dev即可安装
重启QT。

附参考链接
https://blog.csdn.net/qq_41260987/article/details/80975842

用了上面的命令还有问题

如下
[sudo] password for www:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package libgl1-mesa-dev is not available, but is referred to by another package,This may mean that the package is missing, has been obsoleted,
or is only available from another source

E: Package 'libgl1-mesa-dev' has no installation candidate

那么先更新
用以下命令:
sudo apt-get update
sudo apt-get upgrade

更新完以后继续用上面的命令。

附参考链接
https://blog.csdn.net/magic_ninja/article/details/87981662
安装完mesa
重启Qt运行helloworld项目


运行成功

发布了1 篇原创文章 · 获赞 3 · 访问量 105

猜你喜欢

转载自blog.csdn.net/weixin_42232238/article/details/104381592