Problem 1:C++标准以及链接库问题,这个问题的根本原因是由于pangolin在版本升级过程中出现的c++版本兼容不同导致
报错显示如下:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
显然是C++11标准的问题,因此在CMakeLists.txt文件中指定C++11
add_definitions(-std=c++11)
Problem 2: pangolin的一些函数没有定义,说明pangolin没有被链接
报错显示如下:
CMakeFiles/plat_analyse.dir/main.cpp.o:(.data+0x0): undefined reference to `vtable for pangolin::Handler'
包含了pangolin库的头文件,而pangolin的一些函数没有定义,说明pangolin没有被链接,在CMakeLists.txt中继续添加
target_link_libraries(plat_analyse pangolin)
Problem 3: 缺少GL库链接
查找到这个东西在OpenGL库中,说明OpenGL库没有被链接,查找OpenGL库的头文件,其中一个是gl.h,通过下面指令找到gl.h所在目录是/usr/include/GL
报错显示如下:
/usr/bin/ld: CMakeFiles/plat_analyse.dir/main.cpp.o: undefined reference to symbol 'glTexImage2D'
sudo find / -name gl.h
一般目录名对应的就是库名,所以CMakeLists.txt中添加(通过sudo find / -name libGL*命令的确查找到这个库)
添加链接GL库的原因
target_link_libraries(plat_analyse GL)
Problem 4: 缺少GLEW库链接
报错显示如下:
/usr/bin/ld: CMakeFiles/plat_analyse.dir/main.cpp.o: undefined reference to symbol '__glewDeleteBuffers'
同样是库没有链接GLEW库的原因,继续添加
target_link_libraries(plat_analyse GLEW)
C++项目配置错误及解决方法:C++11、pangolin库和OpenGL库链接问题
本文详细介绍了在C++项目中遇到的四个问题及其解决方案。问题涉及C++11标准不匹配、pangolin库未正确链接、缺失GL库链接以及GLEW库未链接。通过修改CMakeLists.txt文件,分别添加了C++11标准指定、pangolin库、OpenGL库和GLEW库的链接选项,成功解决了这些问题。
3921

被折叠的 条评论
为什么被折叠?



