Ubuntu20.04编译编译视觉SLAM十四讲slambook2/ch7

error:

In file included from /usr/local/include/g2o/core/base_unary_edge.h:30,
                 from /home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:8:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:179:32: error: ‘index_sequence’ is not a member of ‘std’
  179 |   struct HessianTupleType> {
      |                                ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:179:32: error: ‘index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:179:51: error: expected parameter pack before ‘...’
  179 |   struct HessianTupleType> {
      |                                                   ^~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:179:51: error: template argument 1 is invalid
/usr/local/include/g2o/core/base_fixed_sized_edge.h:179:54: error: expected unqualified-id before ‘>’ token
  179 |   struct HessianTupleType> {
      |                                                      ^~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:186:38: error: ‘make_index_sequence’ is not a member of ‘std’
  186 |       typename HessianTupleType>::type;
      |                                      ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:186:38: error: ‘make_index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:186:58: error: template argument 1 is invalid
  186 |       typename HessianTupleType>::type;
      |                                                          ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:186:16: error: expected nested-name-specifier
  186 |       typename HessianTupleType>::type;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:188:38: error: ‘make_index_sequence’ is not a member of ‘std’
  188 |       typename HessianTupleType>::typeTransposed;
      |                                      ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:188:38: error: ‘make_index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:188:58: error: template argument 1 is invalid
  188 |       typename HessianTupleType>::typeTransposed;
      |                                                          ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:188:16: error: expected nested-name-specifier
  188 |       typename HessianTupleType>::typeTransposed;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:208:32: error: ‘std::index_sequence’ has not been declared
  208 |   bool allVerticesFixedNs(std::index_sequence) const;
      |                                ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:208:46: error: expected ‘,’ or ‘...’ before ‘<’ token
  208 |   bool allVerticesFixedNs(std::index_sequence) const;
      |                                              ^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:213:75: error: ‘std::index_sequence’ has not been declared
  213 | izeOplus_allocate(JacobianWorkspace& jacobianWorkspace, std::index_sequence);
      |                                                              ^~~~~~~~~~~~~~

/usr/local/include/g2o/core/base_fixed_sized_edge.h:213:89: error: expected ‘,’ or ‘...’ before ‘<’ token
  213 | s_allocate(JacobianWorkspace& jacobianWorkspace, std::index_sequence);
      |                                                                     ^

/usr/local/include/g2o/core/base_fixed_sized_edge.h:221:30: error: ‘std::index_sequence’ has not been declared
  221 |   void linearizeOplusNs(std::index_sequence);
      |                              ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:221:44: error: expected ‘,’ or ‘...’ before ‘<’ token
  221 |   void linearizeOplusNs(std::index_sequence);
      |                                            ^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:245:38: error: ‘std::index_sequence’ has not been declared
  245 |                                 std::index_sequence);
      |                                      ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:245:52: error: expected ‘,’ or ‘...’ before ‘<’ token
  245 |                                 std::index_sequence);
      |                                                    ^
/usr/local/include/g2o/core/base_fixed_sized_edge.h:250:65: error: ‘std::index_sequence’ has not been declared
  250 | oid constructOffDiagonalQuadraticFormMs(const AtOType&, std::index_sequence<>);
      |                                                              ^~~~~~~~~~~~~~

/usr/local/include/g2o/core/base_fixed_sized_edge.h:250:79: error: expected ‘,’ or ‘...’ before ‘<’ token
  250 | ffDiagonalQuadraticFormMs(const AtOType&, std::index_sequence<>);
      |                                                              ^

/usr/local/include/g2o/core/base_fixed_sized_edge.h:253:69: error: ‘std::index_sequence’ has not been declared
  253 | constructOffDiagonalQuadraticFormMs(const AtOType& AtO, std::index_sequence);
      |                                                              ^~~~~~~~~~~~~~

/usr/local/include/g2o/core/base_fixed_sized_edge.h:253:83: error: expected ‘,’ or ‘...’ before ‘<’ token
  253 | ctOffDiagonalQuadraticFormMs(const AtOType& AtO, std::index_sequence);
      |                                                                     ^

/usr/local/include/g2o/core/base_fixed_sized_edge.h:270:3: error: ‘HessianTuple’ does not name a type; did you mean ‘HessianTupleType’?
  270 |   HessianTuple _hessianTuple;
      |   ^~~~~~~~~~~~
      |   HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.h:271:3: error: ‘HessianTupleTransposed’ does not name a type; did you mean ‘HessianTupleType’?
  271 |   HessianTupleTransposed _hessianTupleTransposed;
      |   ^~~~~~~~~~~~~~~~~~~~~~
      |   HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.h: In constructor ‘g2o::BaseFixedSizedEdge::BaseFixedSizedEdge()’:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:193:9: error: class ‘g2o::BaseFixedSizedEdge’ does not have any field named ‘_hessianTuple’
  193 |         _hessianTuple(internal::createHessianMaps(_hessianTuple)),
      |         ^~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:193:51: error: ‘_hessianTuple’ was not declared in this scope; did you mean ‘HessianTupleType’?
  193 |         _hessianTuple(internal::createHessianMaps(_hessianTuple)),
      |                                                   ^~~~~~~~~~~~~
      |                                                   HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.h:194:9: error: class ‘g2o::BaseFixedSizedEdge’ does not have any field named ‘_hessianTupleTransposed’
  194 |         _hessianTupleTransposed(internal::createHessianMaps(_hessianTupleTransposed)),
      |         ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:194:61: error: ‘_hessianTupleTransposed’ was not declared in this scope
  194 |         _hessianTupleTransposed(internal::createHessianMaps(_hessianTupleTransposed)),
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/g2o/core/base_fixed_sized_edge.h:278,
                 from /usr/local/include/g2o/core/base_unary_edge.h:30,
                 from /home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:8:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: At global scope:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:35:6: error: ‘bool g2o::BaseFixedSizedEdge::allVerticesFixedNs’ is not a static data member of ‘class g2o::BaseFixedSizedEdge’
   35 | bool BaseFixedSizedEdge::allVerticesFixedNs(
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:36:10: error: template definition of non-template ‘bool g2o::BaseFixedSizedEdge::allVerticesFixedNs’
   36 |     std::index_sequence) const {
      |          ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:36:10: error: ‘index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘virtual bool g2o::BaseFixedSizedEdge::allVerticesFixed() const’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:43:34: error: ‘make_index_sequence’ is not a member of ‘std’
   43 |   return allVerticesFixedNs(std::make_index_sequence<_nr_of_vertices>());
      |                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:43:71: error: expected primary-expression before ‘)’ token
   43 |   return allVerticesFixedNs(std::make_index_sequence<_nr_of_vertices>());
      |                                                                       ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘virtual void g2o::BaseFixedSizedEdge::constructQuadraticForm()’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:55:35: error: ‘make_index_sequence’ is not a member of ‘std’
   55 |                              std::make_index_sequence<_nr_of_vertices>());
      |                                   ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:55:72: error: expected primary-expression before ‘)’ token
   55 |                              std::make_index_sequence<_nr_of_vertices>());
      |                                                                        ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:58:35: error: ‘make_index_sequence’ is not a member of ‘std’
   58 |                              std::make_index_sequence<_nr_of_vertices>());
      |                                   ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:58:72: error: expected primary-expression before ‘)’ token
   58 |                              std::make_index_sequence<_nr_of_vertices>());
      |                                                                        ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: At global scope:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:65:74: error: ‘std::index_sequence’ has not been declared
   65 | formationType& omega, const ErrorVector& weightedError, std::index_sequence) {
      |                                                              ^~~~~~~~~~~~~~

/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:65:88: error: expected ‘,’ or ‘...’ before ‘<’ token
   65 | nType& omega, const ErrorVector& weightedError, std::index_sequence) {
      |                                                                    ^

/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:75:26: error: ‘std::index_sequence’ has not been declared
   75 |     const AtOType&, std::index_sequence<>) {}
      |                          ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:75:40: error: expected ‘,’ or ‘...’ before ‘<’ token
   75 |     const AtOType&, std::index_sequence<>) {}
      |                                        ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:80:30: error: ‘std::index_sequence’ has not been declared
   80 |     const AtOType& AtO, std::index_sequence) {
      |                              ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:80:44: error: expected ‘,’ or ‘...’ before ‘<’ token
   80 |     const AtOType& AtO, std::index_sequence) {
      |                                            ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘void g2o::BaseFixedSizedEdge::constructOffDiagonalQuadraticFormM(const AtOType&)’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:98:45: error: ‘_hessianTupleTransposed’ was not declared in this scope; did you mean ‘hessianTransposed’?
   98 |       auto& hessianTransposed = std::get(_hessianTupleTransposed);
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~
      |                                             hessianTransposed
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:101:35: error: ‘_hessianTuple’ was not declared in this scope; did you mean ‘HessianTupleType’?
  101 |       auto& hessian = std::get(_hessianTuple);
      |                                   ^~~~~~~~~~~~~
      |                                   HessianTupleType
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘void g2o::BaseFixedSizedEdge::constructQuadraticFormN(const InformationType&, const ErrorVector&)’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:122:54: error: ‘make_index_sequence’ is not a member of ‘std’
  122 |     constructOffDiagonalQuadraticFormMs(AtO, std::make_index_sequence<_nr_of_vertices - N - 1>());
      |                                                      ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:122:99: error: expected primary-expression before ‘)’ token
  122 | Ms(AtO, std::make_index_sequence<_nr_of_vertices - N - 1>());
      |                                                              ^

/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘virtual void g2o::BaseFixedSizedEdge::linearizeOplus(g2o::JacobianWorkspace&)’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:129:51: error: ‘make_index_sequence’ is not a member of ‘std’
  129 |   linearizeOplus_allocate(jacobianWorkspace, std::make_index_sequence<_nr_of_vertices>());
      |                                                   ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:129:88: error: expected primary-expression before ‘)’ token
  129 | jacobianWorkspace, std::make_index_sequence<_nr_of_vertices>());
      |                                                              ^

/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: At global scope:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:136:48: error: ‘std::index_sequence’ has not been declared
  136 |     JacobianWorkspace& jacobianWorkspace, std::index_sequence) {
      |                                                ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:136:62: error: expected ‘,’ or ‘...’ before ‘<’ token
  136 |     JacobianWorkspace& jacobianWorkspace, std::index_sequence) {
      |                                                              ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:190:70: error: variable or field ‘linearizeOplusNs’ declared void
  190 | eFixedSizedEdge::linearizeOplusNs(std::index_sequence) {
      |                                                              ^~~~~~~~~~~~~~

/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:190:70: error: ‘index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘virtual void g2o::BaseFixedSizedEdge::linearizeOplus()’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:199:25: error: ‘make_index_sequence’ is not a member of ‘std’
  199 |   linearizeOplusNs(std::make_index_sequence<_nr_of_vertices>());
      |                         ^~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:199:62: error: expected primary-expression before ‘)’ token
  199 |   linearizeOplusNs(std::make_index_sequence<_nr_of_vertices>());
      |                                                              ^
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp: In member function ‘virtual void g2o::BaseFixedSizedEdge::mapHessianMemory(number_t*, int, int, bool)’:
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:225:57: error: ‘_hessianTupleTransposed’ was not declared in this scope
  225 |     tuple_apply_i(MapHessianMemoryK{d, vj_dim, vi_dim}, _hessianTupleTransposed,
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:228:57: error: ‘_hessianTuple’ was not declared in this scope; did you mean ‘HessianTupleType’?
  228 |     tuple_apply_i(MapHessianMemoryK{d, vi_dim, vj_dim}, _hessianTuple,
      |                                                         ^~~~~~~~~~~~~
      |                                                         HessianTupleType
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp: In member function ‘virtual bool VertexPose::read(std::istream&)’:
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:262:44: warning: no return statement in function returning non-void [-Wreturn-type]
  262 |   virtual bool read(istream &in) override {}
      |                                            ^
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp: In member function ‘virtual bool VertexPose::write(std::ostream&) const’:
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:264:52: warning: no return statement in function returning non-void [-Wreturn-type]
  264 |   virtual bool write(ostream &out) const override {}
      |                                                    ^
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp: In member function ‘virtual bool EdgeProjection::read(std::istream&)’:
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:298:44: warning: no return statement in function returning non-void [-Wreturn-type]
  298 |   virtual bool read(istream &in) override {}
      |                                            ^
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp: In member function ‘virtual bool EdgeProjection::write(std::ostream&) const’:
/home/liqiang/slambook2/ch7/pose_estimation_3d2d.cpp:300:52: warning: no return statement in function returning non-void [-Wreturn-type]
  300 |   virtual bool write(ostream &out) const override {}
      |                                                    ^
make[2]: *** [CMakeFiles/pose_estimation_3d2d.dir/build.make:63: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/pose_estimation_3d2d.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Ubuntu20.04编译编译视觉SLAM十四讲slambook2/ch7_第1张图片

 

解决办法:

将CMakeLists文件里的:

set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")

改为:

set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4")

因为Ubuntu20.04默认安装的是c++14!!!!

 

cmake_minimum_required(VERSION 2.8)
project(vo1)

set(CMAKE_BUILD_TYPE "Release")
add_definitions("-DENABLE_SSE")
#set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")
set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4") 

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(OpenCV 3 REQUIRED)
find_package(G2O REQUIRED)
find_package(Sophus REQUIRED)

include_directories(
        ${OpenCV_INCLUDE_DIRS}
        ${G2O_INCLUDE_DIRS}
        ${Sophus_INCLUDE_DIRS}
        "/usr/local/include/eigen3/"
       
)

add_executable(orb_cv orb_cv.cpp)
target_link_libraries(orb_cv ${OpenCV_LIBS} fmt)

add_executable(orb_self orb_self.cpp)
target_link_libraries(orb_self ${OpenCV_LIBS} fmt)

# add_executable( pose_estimation_2d2d pose_estimation_2d2d.cpp extra.cpp ) # use this if in OpenCV2 
add_executable(pose_estimation_2d2d pose_estimation_2d2d.cpp)
target_link_libraries(pose_estimation_2d2d ${OpenCV_LIBS} fmt)

# # add_executable( triangulation triangulation.cpp extra.cpp) # use this if in opencv2
add_executable(triangulation triangulation.cpp)
target_link_libraries(triangulation ${OpenCV_LIBS} fmt)

add_executable(pose_estimation_3d2d pose_estimation_3d2d.cpp)
target_link_libraries(pose_estimation_3d2d
        g2o_core g2o_stuff
        ${OpenCV_LIBS} fmt)

add_executable(pose_estimation_3d3d pose_estimation_3d3d.cpp)
target_link_libraries(pose_estimation_3d3d
        g2o_core g2o_stuff
        ${OpenCV_LIBS} fmt)

如果有其他错误,可以参考上篇博客:

ubuntu18.04编译视觉SLAM十四讲slambook2/ch7_nudt一枚研究生-CSDN博客

我试了一下用原来那个CMakeLists也可以编译成功:

主要我的这台电脑在 "/usr/include/eigen3/"安装了eigen3。

最后执行效果如下图所示:

个人觉得Ubuntu20.04这只猫真的很好看!!

你可能感兴趣的:(视觉SLAM十四讲,linux)