当前项目结构
cmake_modules/
├── FindCSparse.cmake
├── FindG2O.cmake
└── FindGlog.cmake
include/ # 头文件
└── myslam
├── camera.h
├── common_include.h
└── frame.h
src/ # 源文件
├── camera.cpp
├── CMakeLists.txt
└── frame.cpp
test/ # 测式文件
错误记录
/usr/local/include/glog/vlog_is_on.h:71:4: error: #error <glog/vlog_is_on.h> was not included correctly. See the documentation for how to consume the library.
在对应的src/CMakeLists.txt文件中加入下列代码
find_package(glog REQUIRED)
target_link_libraries(myslam glog::glog)
错误2
In file included from /home/zhouyuxu/Desktop/vslam/myslam/include/myslam/common_include.h:114:0,
from /home/zhouyuxu/Desktop/vslam/myslam/include/myslam/camera.h:7,
from /home/zhouyuxu/Desktop/vslam/myslam/include/myslam/frame.h:7,
from /home/zhouyuxu/Desktop/vslam/myslam/src/frame.cpp:4:
/usr/local/include/glog/logging.h: In constructor ‘google::LogMessage::LogStream::LogStream(google::LogMessage::LogStream&&)’:
/usr/local/include/glog/logging.h:1213:21: error: ‘exchange’ is not a member of ‘std’
编译器版本问题:使用的编译器版本可能不支持 C++14 的标准函数模板。确保您的编译器支持 C++14 标准,并已正确配置。
将父MakeLists.txt中的C++11换成c++14
#set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
#set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -O3 -fopenmp -pthread")
替换后的
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++14 -O3 -fopenmp -pthread")