linux下QT编译出现collect2:ld returned 1 exit status错误的原因之一是未安装mesa
sudo apt install libgl1-mesa-dev
重启qt
自己遇到的原因是:链接库问题
在.pro文件里:
# opencv
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += -L/usr/local/lib/libopencv_*.so
改成:
# opencv
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += -L /usr/local/lib/libopencv_*.so
或:(若使用以上链接库的方式出现undefined undefined reference to xxx的情况,我尝试将opencv的库罗列出来,就编译通过了)
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2