安装后,在代码中包含pangolin.h后编译,会出现错误
/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)
再次编译出现错误
CMakeFiles/plottrajectory.dir/main.cpp.o:(.data+0x0): undefined reference to `vtable for pangolin::Handler'
包含了pangolin库的头文件,而pangolin的一些函数没有定义,说明pangolin没有被链接,在CMakeLists.txt中继续添加
target_link_libraries(plottrajectory pangolin)
再次编译出现错误
/usr/bin/ld: CMakeFiles/plottrajectory.dir/main.cpp.o: undefined reference to symbol 'glTexImage2D'
百度查找到这个东西在OpenGL库中,说明OpenGL库没有被链接
百度查找OpenGL库的头文件,其中一个是gl.h,通过下面指令找到gl.h所在目录是/usr/include/GL
sudo find / -name gl.h
一般

本文详细讲述了在使用C++11标准编译时遇到的错误,涉及pangolin库的安装和链接过程。通过一步步排查,解决了编译期间的缺失链接问题,包括C++11标准支持、pangolin、OpenGL、GLEW等库的链接。
最低0.47元/天 解锁文章
3944





