在正常安装了Sophus库后,运行高博的代码,发现如下错误
####
#### Running command: "make -j16 -l16" in "/home/a/SLAM/slam_ws/build"
####
Scanning dependencies of target useSophus
[ 33%] Built target hello
[ 33%] Built target hello_shared
[ 33%] Built target plotTrajectory
[ 44%] Built target helloSLAM
[ 55%] Built target useGeometry
[ 72%] Built target cooridinateTransform
[ 77%] Built target eigenMatrix
[ 83%] Building CXX object ch4/CMakeFiles/useSophus.dir/src/useSophus.cpp.o
[ 94%] Built target useHello
[100%] Linking CXX executable /home/a/SLAM/slam_ws/devel/lib/ch4/useSophus
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `std::make_unsigned<long>::type fmt::v8::detail::to_unsigned<long>(long)':
/usr/local/include/fmt/core.h:426: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':
/usr/local/include/fmt/core.h:426: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::print<Eigen::Product<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Transpose<Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, 0> const>(fmt::v8::basic_format_string<char, fmt::v8::type_identity<Eigen::Product<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Transpose<Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, 0> const>::type>, Eigen::Product<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Transpose<Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, 0> const&&)':
/usr/local/include/fmt/core.h:3208: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::print<>(fmt::v8::basic_format_string<char>)':
/usr/local/include/fmt/core.h:3208: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::print<double>(fmt::v8::basic_format_string<char, fmt::v8::type_identity<double>::type>, double&&)':
/usr/local/include/fmt/core.h:3208: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::print<>(fmt::v8::basic_format_string<char>)':
/usr/local/include/fmt/core.h:3208: undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler>::on_error(char const*)':
/usr/local/include/fmt/core.h:693: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `char const* fmt::v8::detail::parse_align<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)':
/usr/local/include/fmt/core.h:2302: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `int fmt::v8::detail::parse_nonnegative_int<char>(char const*&, char const*, int)':
/usr/local/include/fmt/core.h:2278: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `char const* fmt::v8::detail::parse_width<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)':
/usr/local/include/fmt/core.h:2399: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::detail::check_string_type_spec<fmt::v8::detail::error_handler&>(fmt::v8::presentation_type, fmt::v8::detail::error_handler&)':
/usr/local/include/fmt/core.h:2805: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::detail::format_value<char, Eigen::Product<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Transpose<Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, 0> >(fmt::v8::detail::buffer<char>&, Eigen::Product<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Transpose<Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, 0> const&, fmt::v8::detail::locale_ref)':
/usr/local/include/fmt/ostream.h:75: undefined reference to `std::locale fmt::v8::detail::locale_ref::get<std::locale>() const'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `fmt::v8::detail::fill_t<char>::operator=(fmt::v8::basic_string_view<char>)':
/usr/local/include/fmt/core.h:2041: undefined reference to `fmt::v8::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `char const* fmt::v8::detail::do_parse_arg_id<char, fmt::v8::detail::parse_width<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)::width_adapter&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)':
/usr/local/include/fmt/core.h:2346: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `char const* fmt::v8::detail::do_parse_arg_id<char, fmt::v8::detail::parse_precision<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)::precision_adapter&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)':
/usr/local/include/fmt/core.h:2346: undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `int fmt::v8::detail::get_dynamic_spec<fmt::v8::detail::width_checker, fmt::v8::basic_format_arg<fmt::v8::basic_format_context<fmt::v8::appender, char> >, fmt::v8::detail::error_handler>(fmt::v8::basic_format_arg<fmt::v8::basic_format_context<fmt::v8::appender, char> >, fmt::v8::detail::error_handler)':
/usr/local/include/fmt/format.h:2287: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `int fmt::v8::detail::get_dynamic_spec<fmt::v8::detail::precision_checker, fmt::v8::basic_format_arg<fmt::v8::basic_format_context<fmt::v8::appender, char> >, fmt::v8::detail::error_handler>(fmt::v8::basic_format_arg<fmt::v8::basic_format_context<fmt::v8::appender, char> >, fmt::v8::detail::error_handler)':
/usr/local/include/fmt/format.h:2287: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `void fmt::v8::detail::check_string_type_spec<fmt::v8::detail::error_handler>(fmt::v8::presentation_type, fmt::v8::detail::error_handler&&)':
/usr/local/include/fmt/core.h:2805: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<int, 0>(int)':
/usr/local/include/fmt/format.h:2249: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<unsigned int, 0>(unsigned int)':
/usr/local/include/fmt/format.h:2249: undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/useSophus.dir/src/useSophus.cpp.o:/usr/local/include/fmt/format.h:2249: more undefined references to `fmt::v8::detail::error_handler::on_error(char const*)' follow
collect2: error: ld returned 1 exit status
make[2]: *** [ch4/CMakeFiles/useSophus.dir/build.make:84:/home/a/SLAM/slam_ws/devel/lib/ch4/useSophus] 错误 1
make[1]: *** [CMakeFiles/Makefile2:878:ch4/CMakeFiles/useSophus.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j16 -l16" failed
可能是因为没有进行连接吧,编译器没有找到Sophus库
只需要将CMakeList.txt文件改一下就好了
原文件
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
add_executable( useSophus useSophus.cpp)
更改后文件
include_directories("/usr/include/eigen3")
set(CMAKE_BUILD_TYPE "Debug")
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
add_executable( useSophus useSophus.cpp)
target_link_libraries(useSophus Sophus::Sophus)