安装后,在代码中包含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
一般目录名对应的就是库名,所以CMakeLists.txt中添加(通过sudo find / -name libGL*命令的确查找到这个库)
target_link_libraries(plottrajectory GL)
再次编译出现错误
/usr/bin/ld: CMakeFiles/plottrajectory.dir/main.cpp.o: undefined reference to symbol '__glewDeleteBuffers'
同样是库没有链接GLEW库的原因,继续添加
target_link_libraries(plottrajectory GLEW)
至此,pangolin库可以正常使用