视觉SLAM十四讲 ch4 trajectoryError.cpp报错问题和解决

首先来看一下我的CMakelist文件:

cmake_minimum_required(VERSION 3.0)
project(trajectoryError)
# 在cmake脚本中,设置编译选项可以通过add_compile_options命令,也可以通过set命令修改CMAKE_CXX_FLAGS或CMAKE_C_FLAGS。
# add_compile_options(-std=c++11) # 这句话的意思是在make时让编译器(g++)自动添加C++11的性质 -> 设置编译选项

option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" ON)
find_package(Pangolin REQUIRED)
if(USE_UBUNTU_20)
    message("You are using Ubuntu 20.04, fmt::fmt will be linked")
    find_package(fmt REQUIRED)
    set(FMT_LIBRARIES fmt::fmt)
endif()
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(trajectoryError trajectoryError.cpp)
target_link_libraries(trajectoryError ${FMT_LIBRARIES})
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES})

set(CMAKE_BUILD_TYPE "Release")
set(Sophus_LIBRARIES  "/usr/local/lib/libSophus.so")
find_package(Sophus REQUIRED)
include_directories( ${Sophus_INCLUDE_DIRS} )
target_link_libraries(trajectoryError ${Sophus_LIBRARIES})

修改了cmakelist文件可以解决大部分的由于库链接出现问题所导致的报错。
然后再看一下代码的需要修改的地方:
请添加图片描述
请添加图片描述
我们需要把头文件对应起来,原来的头文件需要与安装在本地(sophus支持带模板的,可以选择不安装)的文件名字对应,具体是后缀为.h还是.hpp需要根据自己的电脑对应起来。
修改完之后大部分的错误可以解决了。
请添加图片描述
请添加图片描述
如果cmake时遇到了这样的错误的话:

[ 50%] Building CXX object CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o
In file included from /usr/local/include/pangolin/utils/signal_slot.h:3,
                 from /usr/local/include/pangolin/windowing/window.h:35,
                 from /usr/local/include/pangolin/display/display.h:34,
                 from /usr/local/include/pangolin/pangolin.h:38,
                 from /home/hbt/文档/slambook2/ch4/example/trajectoryError.cpp:4:
/usr/local/include/sigslot/signal.hpp:109:79: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  109 | constexpr bool is_weak_ptr_compatible_v = detail::is_weak_ptr_compatible>::value;
      |                                                                               ^~~~~~~
      |                                                                               decay
/usr/local/include/sigslot/signal.hpp:109:79: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  109 | constexpr bool is_weak_ptr_compatible_v = detail::is_weak_ptr_compatible>::value;
      |                                                                               ^~~~~~~
      |                                                                               decay
/usr/local/include/sigslot/signal.hpp:109:87: error: template argument 1 is invalid
  109 | constexpr bool is_weak_ptr_compatible_v = detail::is_weak_ptr_compatible>::value;
      |                                                                                       ^
/usr/local/include/sigslot/signal.hpp:109:92: error: ‘::value’ has not been declared
  109 | constexpr bool is_weak_ptr_compatible_v = detail::is_weak_ptr_compatible>::value;
      |                                                                                            ^~~~~
/usr/local/include/sigslot/signal.hpp:132:53: error: ‘remove_pointer_t’ is not a member of ‘std’; did you mean ‘remove_pointer’?
  132 |                                                std::remove_pointer_t>::value;
      |                                                     ^~~~~~~~~~~~~~~~
      |                                                     remove_pointer
/usr/local/include/sigslot/signal.hpp:132:53: error: ‘remove_pointer_t’ is not a member of ‘std’; did you mean ‘remove_pointer’?
  132 |                                                std::remove_pointer_t>::value;
      |                                                     ^~~~~~~~~~~~~~~~
      |                                                     remove_pointer
/usr/local/include/sigslot/signal.hpp:132:70: error: template argument 2 is invalid
  132 |                                                std::remove_pointer_t>::value;
      |                                                                      ^
/usr/local/include/sigslot/signal.hpp:132:75: error: ‘::value’ has not been declared
  132 |                                                std::remove_pointer_t>::value;
      |                                                                           ^~~~~
/usr/local/include/sigslot/signal.hpp:223:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  223 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:223:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  223 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:223:62: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::function_traits’
  223 | struct function_traits>> {
      |                                                              ^~
/usr/local/include/sigslot/signal.hpp:223:62: note:   expected a type, got ‘( < is_func_v)’
/usr/local/include/sigslot/signal.hpp:223:64: error: expected unqualified-id before ‘>’ token
  223 | struct function_traits>> {
      |                                                                ^
/usr/local/include/sigslot/signal.hpp:233:33: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  233 | struct function_traits>> {
      |                                 ^~~~~~~~~~~
      |                                 enable_if
/usr/local/include/sigslot/signal.hpp:233:33: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  233 | struct function_traits>> {
      |                                 ^~~~~~~~~~~
      |                                 enable_if
/usr/local/include/sigslot/signal.hpp:233:63: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::function_traits’
  233 | struct function_traits>> {
      |                                                               ^~
/usr/local/include/sigslot/signal.hpp:233:63: note:   expected a type, got ‘( < is_func_v)’
/usr/local/include/sigslot/signal.hpp:233:65: error: expected unqualified-id before ‘>’ token
  233 | struct function_traits>> {
      |                                                                 ^
/usr/local/include/sigslot/signal.hpp:243:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  243 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:243:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  243 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:243:61: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::function_traits’
  243 | struct function_traits>> {
      |                                                             ^~
/usr/local/include/sigslot/signal.hpp:243:61: note:   expected a type, got ‘( < is_pmf_v)’
/usr/local/include/sigslot/signal.hpp:243:63: error: expected unqualified-id before ‘>’ token
  243 | struct function_traits>> {
      |                                                               ^
/usr/local/include/sigslot/signal.hpp:254:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  254 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:254:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  254 | struct function_traits>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:254:72: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::function_traits’
  254 | struct function_traits>> {
      |                                                                        ^~
/usr/local/include/sigslot/signal.hpp:254:72: note:   expected a type, got ‘( < has_call_operator_v)’
/usr/local/include/sigslot/signal.hpp:254:74: error: expected unqualified-id before ‘>’ token
  254 | struct function_traits>> {
      |                                                                          ^
/usr/local/include/sigslot/signal.hpp: In function ‘sigslot::detail::func_ptr sigslot::detail::get_function_ptr(const T&)’:
/usr/local/include/sigslot/signal.hpp:269:26: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  269 |     function_traits>::ptr(t, d);
      |                          ^~~~~~~
      |                          decay
/usr/local/include/sigslot/signal.hpp:269:26: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
  269 |     function_traits>::ptr(t, d);
      |                          ^~~~~~~
      |                          decay
/usr/local/include/sigslot/signal.hpp:269:34: error: template argument 1 is invalid
  269 |     function_traits>::ptr(t, d);
      |                                  ^
/usr/local/include/sigslot/signal.hpp:269:35: error: expected unqualified-id before ‘>’ token
  269 |     function_traits>::ptr(t, d);
      |                                   ^~
/usr/local/include/sigslot/signal.hpp: At global scope:
/usr/local/include/sigslot/signal.hpp:291:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  291 | struct object_pointer>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:291:32: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  291 | struct object_pointer>> {
      |                                ^~~~~~~~~~~
      |                                enable_if
/usr/local/include/sigslot/signal.hpp:291:66: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::object_pointer’
  291 | struct object_pointer>> {
      |                                                                  ^~
/usr/local/include/sigslot/signal.hpp:291:66: note:   expected a type, got ‘( < is_pointer_v)’
/usr/local/include/sigslot/signal.hpp:291:68: error: expected unqualified-id before ‘>’ token
  291 | struct object_pointer>> {
      |                                                                    ^
/usr/local/include/sigslot/signal.hpp:298:31: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  298 | struct object_pointer>> {
      |                               ^~~~~~~~~~~
      |                               enable_if
/usr/local/include/sigslot/signal.hpp:298:31: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  298 | struct object_pointer>> {
      |                               ^~~~~~~~~~~
      |                               enable_if
/usr/local/include/sigslot/signal.hpp:298:65: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::object_pointer’
  298 | struct object_pointer>> {
      |                                                                 ^~
/usr/local/include/sigslot/signal.hpp:298:65: note:   expected a type, got ‘( < is_weak_ptr_v)’
/usr/local/include/sigslot/signal.hpp:298:67: error: expected unqualified-id before ‘>’ token
  298 | struct object_pointer>> {
      |                                                                   ^
/usr/local/include/sigslot/signal.hpp:306:31: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  306 | struct object_pointer &&
      |                               ^~~~~~~~~~~
      |                               enable_if
/usr/local/include/sigslot/signal.hpp:306:31: error: ‘enable_if_t’ is not a member of ‘std’; did you mean ‘enable_if’?
  306 | struct object_pointer &&
      |                               ^~~~~~~~~~~
      |                               enable_if
/usr/local/include/sigslot/signal.hpp:308:76: error: type/value mismatch at argument 2 in template parameter list for ‘template struct sigslot::detail::object_pointer’
  308 |                                           trait::is_weak_ptr_compatible_v>>
      |                                                                            ^~
/usr/local/include/sigslot/signal.hpp:308:76: note:   expected a type, got ‘((( < (! is_pointer_v)) && (! is_weak_ptr_v)) && is_weak_ptr_compatible_v)’
/usr/local/include/sigslot/signal.hpp:308:78: error: expected unqualified-id before ‘>’ token
  308 |                                           trait::is_weak_ptr_compatible_v>>
      |                                                                              ^
/usr/local/include/sigslot/signal.hpp:398:41: error: ‘std::enable_if_t’ has not been declared
  398 |     explicit copy_on_write(U && x, std::enable_if_t,
      |                                         ^~~~~~~~~~~
/usr/local/include/sigslot/signal.hpp:398:52: error: expected ‘,’ or ‘...’ before ‘<’ token
  398 |     explicit copy_on_write(U && x, std::enable_if_t,
      |                                                    ^
/usr/local/include/sigslot/signal.hpp:532:5: error: ‘index’ function uses ‘auto’ type specifier without trailing return type
  532 |     auto index() const {
      |     ^~~~
/usr/local/include/sigslot/signal.hpp:532:5: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
/usr/local/include/sigslot/signal.hpp:536:5: error: ‘index’ function uses ‘auto’ type specifier without trailing return type
  536 |     auto& index() {
      |     ^~~~
/usr/local/include/sigslot/signal.hpp:536:5: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
/usr/local/include/sigslot/signal.hpp:793:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’?
  793 |     std::enable_if_t::must_check_object, bool>
      |          ^~~~~~~~~~~
      |          enable_if
/usr/local/include/sigslot/signal.hpp:799:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’?
  799 |     std::enable_if_t::must_check_object, bool>
      |          ^~~~~~~~~~~
      |          enable_if
/usr/local/include/sigslot/signal.hpp:876:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’?
  876 |     std::decay_t func;
      |          ^~~~~~~
      |          decay
/usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot::slot(sigslot::detail::cleanable&, F&&, Gid)’:
/usr/local/include/sigslot/signal.hpp:858:11: error: class ‘sigslot::detail::slot’ does not have any field named ‘func’
  858 |         , func{std::forward(f)} {}
      |           ^~~~
/usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot::get_callable() const’:
/usr/local/include/sigslot/signal.hpp:866:33: error: ‘func’ was not declared in this scope; did you mean ‘Func’?
  866 |         return get_function_ptr(func);
      |                                 ^~~~
      |                                 Func
/usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot::get_callable_type() const’:
/usr/local/include/sigslot/signal.hpp:871:23: error: ‘func’ was not declared in this scope; did you mean ‘Func’?
  871 |         return typeid(func);
      |                       ^~~~
      |                       Func
/usr/local/include/sigslot/signal.hpp: At global scope:
/usr/local/include/sigslot/signal.hpp:908:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’?
  908 |     std::decay_t func;
      |          ^~~~~~~
      |          decay
/usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot_extended::slot_extended(sigslot::detail::cleanable&, F&&, sigslot::group_id)’:
/usr/local/include/sigslot/signal.hpp:888:11: error: class ‘sigslot::detail::slot_extended’ does not have any field named ‘func’
  888 |         , func{std::forward(f)} {}
      |           ^~~~
/usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot_extended::get_callable() const’:
/usr/local/include/sigslot/signal.hpp:898:33: error: ‘func’ was not declared in this scope; did you mean ‘Func’?
  898 |         return get_function_ptr(func);
      |                                 ^~~~
      |                                 Func
/usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot_extended::get_callable_type() const’:
/usr/local/include/sigslot/signal.hpp:903:23: error: ‘func’ was not declared in this scope; did you mean ‘Func’?
  903 |         return typeid(func);
      |                       ^~~~
      |                       Func
/usr/local/include/sigslot/signal.hpp: At global scope:
/usr/local/include/sigslot/signal.hpp:945:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’?
  945 |     std::decay_t pmf;
      |          ^~~~~~~
      |          decay
/usr/local/include/sigslot/signal.hpp:946:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’?
  946 |     std::decay_t ptr;
      |          ^~~~~~~
      |          decay
/usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot_pmf::slot_pmf(sigslot::detail::cleanable&, F&&, P&&, sigslot::group_id)’:
/usr/local/include/sigslot/signal.hpp:922:11: error: class ‘sigslot::detail::slot_pmf’ does not have any field named ‘pmf’
  922 |         , pmf{std::forward(f)}
      |           ^~~
/usr/local/include/sigslot/signal.hpp:923:11: error: class ‘sigslot::detail::slot_pmf’ does not have any field named ‘ptr’
  923 |         , ptr{std::forward

(p)} {} | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::detail::slot_pmf::call_slot(Args ...)’: /usr/local/include/sigslot/signal.hpp:927:12: error: ‘ptr’ was not declared in this scope; did you mean ‘Ptr’? 927 | ((*ptr).*pmf)(args...); | ^~~ | Ptr /usr/local/include/sigslot/signal.hpp:927:18: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 927 | ((*ptr).*pmf)(args...); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot_pmf::get_callable() const’: /usr/local/include/sigslot/signal.hpp:931:33: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 931 | return get_function_ptr(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘const void* sigslot::detail::slot_pmf::get_object() const’: /usr/local/include/sigslot/signal.hpp:935:31: error: ‘ptr’ was not declared in this scope; did you mean ‘Ptr’? 935 | return get_object_ptr(ptr); | ^~~ | Ptr /usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot_pmf::get_callable_type() const’: /usr/local/include/sigslot/signal.hpp:940:23: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 940 | return typeid(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: At global scope: /usr/local/include/sigslot/signal.hpp:982:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 982 | std::decay_t pmf; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp:983:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 983 | std::decay_t ptr; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot_pmf_extended::slot_pmf_extended(sigslot::detail::cleanable&, F&&, P&&, sigslot::group_id)’: /usr/local/include/sigslot/signal.hpp:958:11: error: class ‘sigslot::detail::slot_pmf_extended’ does not have any field named ‘pmf’ 958 | , pmf{std::forward(f)} | ^~~ /usr/local/include/sigslot/signal.hpp:959:11: error: class ‘sigslot::detail::slot_pmf_extended’ does not have any field named ‘ptr’ 959 | , ptr{std::forward

(p)} {} | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::detail::slot_pmf_extended::call_slot(Args ...)’: /usr/local/include/sigslot/signal.hpp:965:12: error: ‘ptr’ was not declared in this scope; did you mean ‘Ptr’? 965 | ((*ptr).*pmf)(conn, args...); | ^~~ | Ptr /usr/local/include/sigslot/signal.hpp:965:18: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 965 | ((*ptr).*pmf)(conn, args...); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot_pmf_extended::get_callable() const’: /usr/local/include/sigslot/signal.hpp:969:33: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 969 | return get_function_ptr(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘const void* sigslot::detail::slot_pmf_extended::get_object() const’: /usr/local/include/sigslot/signal.hpp:972:31: error: ‘ptr’ was not declared in this scope; did you mean ‘Ptr’? 972 | return get_object_ptr(ptr); | ^~~ | Ptr /usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot_pmf_extended::get_callable_type() const’: /usr/local/include/sigslot/signal.hpp:977:23: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 977 | return typeid(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: At global scope: /usr/local/include/sigslot/signal.hpp:1032:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 1032 | std::decay_t func; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp:1033:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 1033 | std::decay_t ptr; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot_tracked::slot_tracked(sigslot::detail::cleanable&, F&&, P&&, sigslot::group_id)’: /usr/local/include/sigslot/signal.hpp:997:11: error: class ‘sigslot::detail::slot_tracked’ does not have any field named ‘func’ 997 | , func{std::forward(f)} | ^~~~ /usr/local/include/sigslot/signal.hpp:998:11: error: class ‘sigslot::detail::slot_tracked’ does not have any field named ‘ptr’ 998 | , ptr{std::forward

(p)} | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘bool sigslot::detail::slot_tracked::connected() const’: /usr/local/include/sigslot/signal.hpp:1002:17: error: ‘ptr’ was not declared in this scope 1002 | return !ptr.expired() && slot_state::connected(); | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::detail::slot_tracked::call_slot(Args ...)’: /usr/local/include/sigslot/signal.hpp:1007:19: error: ‘ptr’ was not declared in this scope 1007 | auto sp = ptr.lock(); | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot_tracked::get_callable() const’: /usr/local/include/sigslot/signal.hpp:1018:33: error: ‘func’ was not declared in this scope; did you mean ‘Func’? 1018 | return get_function_ptr(func); | ^~~~ | Func /usr/local/include/sigslot/signal.hpp: In member function ‘const void* sigslot::detail::slot_tracked::get_object() const’: /usr/local/include/sigslot/signal.hpp:1022:31: error: ‘ptr’ was not declared in this scope 1022 | return get_object_ptr(ptr); | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot_tracked::get_callable_type() const’: /usr/local/include/sigslot/signal.hpp:1027:23: error: ‘func’ was not declared in this scope; did you mean ‘Func’? 1027 | return typeid(func); | ^~~~ | Func /usr/local/include/sigslot/signal.hpp: At global scope: /usr/local/include/sigslot/signal.hpp:1082:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 1082 | std::decay_t pmf; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp:1083:10: error: ‘decay_t’ in namespace ‘std’ does not name a template type; did you mean ‘decay’? 1083 | std::decay_t ptr; | ^~~~~~~ | decay /usr/local/include/sigslot/signal.hpp: In constructor ‘constexpr sigslot::detail::slot_pmf_tracked::slot_pmf_tracked(sigslot::detail::cleanable&, F&&, P&&, sigslot::group_id)’: /usr/local/include/sigslot/signal.hpp:1047:11: error: class ‘sigslot::detail::slot_pmf_tracked’ does not have any field named ‘pmf’ 1047 | , pmf{std::forward(f)} | ^~~ /usr/local/include/sigslot/signal.hpp:1048:11: error: class ‘sigslot::detail::slot_pmf_tracked’ does not have any field named ‘ptr’ 1048 | , ptr{std::forward

(p)} | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘bool sigslot::detail::slot_pmf_tracked::connected() const’: /usr/local/include/sigslot/signal.hpp:1052:17: error: ‘ptr’ was not declared in this scope 1052 | return !ptr.expired() && slot_state::connected(); | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::detail::slot_pmf_tracked::call_slot(Args ...)’: /usr/local/include/sigslot/signal.hpp:1057:19: error: ‘ptr’ was not declared in this scope 1057 | auto sp = ptr.lock(); | ^~~ /usr/local/include/sigslot/signal.hpp:1063:21: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 1063 | ((*sp).*pmf)(args...); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::detail::func_ptr sigslot::detail::slot_pmf_tracked::get_callable() const’: /usr/local/include/sigslot/signal.hpp:1068:33: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 1068 | return get_function_ptr(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: In member function ‘const void* sigslot::detail::slot_pmf_tracked::get_object() const’: /usr/local/include/sigslot/signal.hpp:1072:31: error: ‘ptr’ was not declared in this scope 1072 | return get_object_ptr(ptr); | ^~~ /usr/local/include/sigslot/signal.hpp: In member function ‘const std::type_info& sigslot::detail::slot_pmf_tracked::get_callable_type() const’: /usr/local/include/sigslot/signal.hpp:1077:23: error: ‘pmf’ was not declared in this scope; did you mean ‘Pmf’? 1077 | return typeid(pmf); | ^~~ | Pmf /usr/local/include/sigslot/signal.hpp: At global scope: /usr/local/include/sigslot/signal.hpp:1115:27: error: ‘conditional_t’ in namespace ‘std’ does not name a template type; did you mean ‘conditional’? 1115 | using cow_type = std::conditional_t::value, | ^~~~~~~~~~~~~ | conditional /usr/local/include/sigslot/signal.hpp:1119:32: error: ‘conditional_t’ in namespace ‘std’ does not name a template type; did you mean ‘conditional’? 1119 | using cow_copy_type = std::conditional_t::value, | ^~~~~~~~~~~~~ | conditional /usr/local/include/sigslot/signal.hpp:1201:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1201 | std::enable_if_t, connection> | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1221:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1221 | std::enable_if_t, connection> | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1241:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1241 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1261:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1261 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1281:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1281 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1310:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1310 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1340:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1340 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1376:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1376 | std::enable_if_t<(trait::is_callable_v || | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1399:10: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type; did you mean ‘enable_if’? 1399 | std::enable_if_t && | ^~~~~~~~~~~ | enable_if /usr/local/include/sigslot/signal.hpp:1522:12: error: ‘cow_copy_type’ does not name a type 1522 | inline cow_copy_type slots_reference() { | ^~~~~~~~~~~~~ /usr/local/include/sigslot/signal.hpp:1529:12: error: ‘make_slot’ function uses ‘auto’ type specifier without trailing return type 1529 | inline auto make_slot(A && ...a) { | ^~~~ /usr/local/include/sigslot/signal.hpp:1529:12: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’ /usr/local/include/sigslot/signal.hpp:1589:5: error: ‘cow_type’ does not name a type; did you mean ‘lock_type’? 1589 | cow_type m_slots; | ^~~~~~~~ | lock_type /usr/local/include/sigslot/signal.hpp: In constructor ‘sigslot::signal_base< , >::signal_base(sigslot::signal_base< , >&&)’: /usr/local/include/sigslot/signal.hpp:1146:14: error: ‘m_slots’ was not declared in this scope 1146 | swap(m_slots, o.m_slots); | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘sigslot::signal_base< , >& sigslot::signal_base< , >::operator=(sigslot::signal_base< , >&&)’: /usr/local/include/sigslot/signal.hpp:1155:14: error: ‘m_slots’ was not declared in this scope 1155 | swap(m_slots, o.m_slots); | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< , >::operator()(U&& ...)’: /usr/local/include/sigslot/signal.hpp:1180:9: error: ‘cow_copy_type’ was not declared in this scope 1180 | cow_copy_type ref = slots_reference(); | ^~~~~~~~~~~~~ /usr/local/include/sigslot/signal.hpp:1180:32: error: expected primary-expression before ‘,’ token 1180 | cow_copy_type ref = slots_reference(); | ^ /usr/local/include/sigslot/signal.hpp:1180:42: error: expected primary-expression before ‘>’ token 1180 | cow_copy_type ref = slots_reference(); | ^ /usr/local/include/sigslot/signal.hpp:1180:44: error: ‘ref’ was not declared in this scope; did you mean ‘std::ref’? 1180 | cow_copy_type ref = slots_reference(); | ^~~ | std::ref In file included from /usr/include/c++/9/functional:58, from /usr/local/include/pangolin/utils/type_convert.h:33, from /usr/local/include/pangolin/utils/params.h:31, from /usr/local/include/pangolin/display/display.h:33, from /usr/local/include/pangolin/pangolin.h:38, from /home/hbt/文档/slambook2/ch4/example/trajectoryError.cpp:4: /usr/include/c++/9/bits/refwrap.h:370:5: note: ‘std::ref’ declared here 370 | ref(reference_wrapper<_Tp> __t) noexcept | ^~~ In file included from /usr/local/include/pangolin/utils/signal_slot.h:3, from /usr/local/include/pangolin/windowing/window.h:35, from /usr/local/include/pangolin/display/display.h:34, from /usr/local/include/pangolin/pangolin.h:38, from /home/hbt/文档/slambook2/ch4/example/trajectoryError.cpp:4: /usr/local/include/sigslot/signal.hpp:1180:50: error: there are no arguments to ‘slots_reference’ that depend on a template parameter, so a declaration of ‘slots_reference’ must be available [-fpermissive] 1180 | cow_copy_type ref = slots_reference(); | ^~~~~~~~~~~~~~~ /usr/local/include/sigslot/signal.hpp:1180:50: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< , >::disconnect(const Callable&, const Obj&)’: /usr/local/include/sigslot/signal.hpp:1423:41: error: use of ‘auto’ in lambda parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’ 1423 | return disconnect_if([&] (const auto &s) { | ^~~~ /usr/local/include/sigslot/signal.hpp: In lambda function: /usr/local/include/sigslot/signal.hpp:1424:21: error: base operand of ‘->’ is not a pointer 1424 | return s->has_object(obj) && s->has_callable(c); | ^~ /usr/local/include/sigslot/signal.hpp:1424:43: error: base operand of ‘->’ is not a pointer 1424 | return s->has_object(obj) && s->has_callable(c); | ^~ /usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< , >::disconnect(sigslot::group_id)’: /usr/local/include/sigslot/signal.hpp:1439:46: error: ‘m_slots’ was not declared in this scope 1439 | for (auto &group : detail::cow_write(m_slots)) { | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< , >::slot_count()’: /usr/local/include/sigslot/signal.hpp:1486:9: error: ‘cow_copy_type’ was not declared in this scope 1486 | cow_copy_type ref = slots_reference(); | ^~~~~~~~~~~~~ /usr/local/include/sigslot/signal.hpp:1486:32: error: expected primary-expression before ‘,’ token 1486 | cow_copy_type ref = slots_reference(); | ^ /usr/local/include/sigslot/signal.hpp:1486:42: error: expected primary-expression before ‘>’ token 1486 | cow_copy_type ref = slots_reference(); | ^ /usr/local/include/sigslot/signal.hpp:1486:44: error: ‘ref’ was not declared in this scope; did you mean ‘std::ref’? 1486 | cow_copy_type ref = slots_reference(); | ^~~ | std::ref In file included from /usr/include/c++/9/functional:58, from /usr/local/include/pangolin/utils/type_convert.h:33, from /usr/local/include/pangolin/utils/params.h:31, from /usr/local/include/pangolin/display/display.h:33, from /usr/local/include/pangolin/pangolin.h:38, from /home/hbt/文档/slambook2/ch4/example/trajectoryError.cpp:4: /usr/include/c++/9/bits/refwrap.h:370:5: note: ‘std::ref’ declared here 370 | ref(reference_wrapper<_Tp> __t) noexcept | ^~~ In file included from /usr/local/include/pangolin/utils/signal_slot.h:3, from /usr/local/include/pangolin/windowing/window.h:35, from /usr/local/include/pangolin/display/display.h:34, from /usr/local/include/pangolin/pangolin.h:38, from /home/hbt/文档/slambook2/ch4/example/trajectoryError.cpp:4: /usr/local/include/sigslot/signal.hpp:1486:50: error: there are no arguments to ‘slots_reference’ that depend on a template parameter, so a declaration of ‘slots_reference’ must be available [-fpermissive] 1486 | cow_copy_type ref = slots_reference(); | ^~~~~~~~~~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< , >::clean(sigslot::detail::slot_state*)’: /usr/local/include/sigslot/signal.hpp:1504:46: error: ‘m_slots’ was not declared in this scope 1504 | for (auto &group : detail::cow_write(m_slots)) { | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< , >::add_slot(sigslot::signal_base< , >::slot_ptr&&)’: /usr/local/include/sigslot/signal.hpp:1538:42: error: ‘m_slots’ was not declared in this scope 1538 | auto &groups = detail::cow_write(m_slots); | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘size_t sigslot::signal_base< , >::disconnect_if(Cond&&)’: /usr/local/include/sigslot/signal.hpp:1560:42: error: ‘m_slots’ was not declared in this scope 1560 | auto &groups = detail::cow_write(m_slots); | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In member function ‘void sigslot::signal_base< , >::clear()’: /usr/local/include/sigslot/signal.hpp:1584:27: error: ‘m_slots’ was not declared in this scope 1584 | detail::cow_write(m_slots).clear(); | ^~~~~~~ /usr/local/include/sigslot/signal.hpp: In instantiation of ‘void sigslot::signal_base< , >::operator()(U&& ...) [with U = {pangolin::VarState::Event}; Lockable = std::mutex; T = {pangolin::VarState::Event}]’: /usr/local/include/pangolin/var/varstate.h:264:23: required from ‘std::map, std::shared_ptr >::iterator pangolin::VarState::AddUpgradedVar(const std::shared_ptr >&, const iterator&, bool) [with T = bool; std::map, std::shared_ptr >::iterator = std::_Rb_tree_iterator, std::shared_ptr > >]’ /usr/local/include/pangolin/var/varstate.h:205:13: required from ‘std::shared_ptr pangolin::VarState::GetOrCreateVar(const T&, const pangolin::VarMeta&) [with T = bool]’ /usr/local/include/pangolin/var/var.h:83:50: required from ‘pangolin::Var::Var(const T&, const pangolin::VarMeta&) [with T = bool]’ /usr/local/include/pangolin/var/var.h:88:35: required from ‘pangolin::Var::Var(const string&, const T&) [with T = bool; std::string = std::__cxx11::basic_string]’ /usr/local/include/pangolin/display/widgets.h:153:50: required from here /usr/local/include/sigslot/signal.hpp:1180:65: error: ‘slots_reference’ was not declared in this scope 1180 | cow_copy_type ref = slots_reference(); | ~~~~~~~~~~~~~~~^~ make[2]: *** [CMakeFiles/trajectoryError.dir/build.make:63:CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:76:CMakeFiles/trajectoryError.dir/all] 错误 2 make: *** [Makefile:84:all] 错误 2

大部分的原因就是CMakelist文件没有把库链接进来,所以只需要修改cmakelist文件为文章开头那样即可。
然后运行效果如图:
视觉SLAM十四讲 ch4 trajectoryError.cpp报错问题和解决_第1张图片
参考文章:
《视觉SLAM十四讲》第二版源码slambook2编译调试
[cmake:设置编译选项的讲究(add_compile_options和CMAKE_CXX_FLAGS的区别) 转自CSDN](https://blog.csdn.net/bianchengjingling22/article/details/88794329?ops_request_misc=&request_id=&biz_id=102&utm_term=add_compile_options(-std=c++11&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-0-88794329.first_rank_v2_pc_rank_v29&spm=1018.2226.3001.4187)
(.text.startup+0x102):对‘Sophus::SO3::operator*(Sophus::SO3 const&) const’未定义的引用

你可能感兴趣的:(ros,c++,ubuntu,slam,linux)