在使用Qt Creator创建并编译新项目时,可能会遇到以下错误:
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
这个问题通常出现在新安装系统或者配置不完整时,原因是系统找不到OpenGL库。以下是几种解决方法。
方法一:安装必要的OpenGL开发库
在Ubuntu上,安装libgl1-mesa-dev
包可以解决这个问题。这是推荐的解决方法:
sudo apt install libgl1-mesa-dev
方法二:手动创建符号链接
如果安装libgl1-mesa-dev
包后问题仍然存在或者你希望避免安装额外的软件包,你可以手动创建符号链接:
-
首先使用
locate
命令找到libGL
库的位置:locate libGL