章节目录
/ch2
编译正常,log如下:
slambook2-master/ch2# mkdir build && cd build && cmake .. && make -j16
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/slam14/slambook2-master/ch2/build
[ 37%] Building CXX object CMakeFiles/hello_shared.dir/libHelloSLAM.cpp.o
[ 37%] Building CXX object CMakeFiles/helloSLAM.dir/helloSLAM.cpp.o
[ 37%] Building CXX object CMakeFiles/hello.dir/libHelloSLAM.cpp.o
[ 75%] Linking CXX shared library libhello_shared.so
[ 75%] Linking CXX static library libhello.a
[ 75%] Linking CXX executable helloSLAM
[ 75%] Built target hello
[ 75%] Built target hello_shared
[ 75%] Built target helloSLAM
[ 87%] Building CXX object CMakeFiles/useHello.dir/useHello.cpp.o
[100%] Linking CXX executable useHello
[100%] Built target useHello
slambook2-master/ch2/build# ./useHello
Hello SLAM
slambook2-master/ch2/build# ./helloSLAM
Hello SLAM!
/ch3
1.编译问题
[ 50%] Building CXX object useEigen/CMakeFiles/eigenMatrix.dir/eigenMatrix.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 /mnt/d/slam14/slambook2-master/ch3/examples/plotTrajectory.cpp:1:
/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<std::decay_t<P>>::value;
1.解决方案
将CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")注释掉即可
#set(CMAKE_CXX_FLAGS "-std=c++11")
不过编译后运行./visualizeGeometry会有如下报错:
2.编译问题
[ 90%] Building CXX object visualizeGeometry/CMakeFiles/visualizeGeometry.dir/visualizeGeometry.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 /mnt/d/slam14/slambook2-master/ch3/visualizeGeometry/visualizeGeometry.cpp:11:
/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<std::decay_t<P>>::value;
2.解决方案
将CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")注释掉即可
#set(CMAKE_CXX_FLAGS "-std=c++11")
3.编译问题
slambook2-master/ch3/build/visualizeGeometry# ./visualizeGeometry
terminate called after throwing an instance of 'std::runtime_error'
what(): Pangolin X11: Failed to open X display
Aborted
3.解决方案
//TODO有待解决,解决其他问题后一并解决
应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。
4.编译问题
slambook2-master/ch3/build/examples# ./plotTrajectory
cannot find trajectory file at ./examples/trajectory.txt
4.解决方案
//TODO有待解决
/ch4
1.编译问题
[100%] Linking CXX executable trajectoryError
/usr/bin/ld: CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':
trajectoryError.cpp:(.text._ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_]+0x23): undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
1.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
target_link_libraries(useSophus Sophus::Sophus)改为
target_link_libraries(useSophus Sophus::Sophus fmt)
2.编译问题
[ 50%] Linking CXX executable trajectoryError
/usr/bin/ld: CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':
trajectoryError.cpp:(.text._ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_]+0x23): undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'
2.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})改为
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES} fmt)
3.编译问题
slambook2-master/ch4/build/example# ./trajectoryError
trajectory ./example/groundtruth.txt not found.
trajectory ./example/estimated.txt not found.
trajectoryError: /mnt/d/slam14/slambook2-master/ch4/example/trajectoryError.cpp:22: int main(int, char**): Assertion `!groundtruth.empty() && !estimated.empty()' failed.
Aborted
3.解决方案
//TODO有待解决
/ch5
1.编译问题
[ 75%] Linking CXX executable undistortImage
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 /mnt/d/slam14/slambook2-master/ch5/stereo/stereoVision.cpp:5:
/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<std::decay_t<P>>::value;
1.解决方案
将CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")注释掉即可
#set(CMAKE_CXX_FLAGS "-std=c++11")
2.编译问题
[100%] Linking CXX executable joinMap
/usr/bin/ld: CMakeFiles/joinMap.dir/joinMap.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
joinMap.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
2.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将slambook2-master/ch5/rgbd/CMakeLists.txt中:
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES} )改为
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES} fmt)
3.编译问题
(1)slambook2-master/ch5/build/imageBasics# ./imageBasics
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted
(2)slambook2-master/ch5/build/imageBasics# ./undistortImage
[ WARN:0@0.001] global /mnt/d/slam14/wsl_libs/opencv-4.x/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('./distorted.png'): can't open/read file: check file path/integrity
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1000: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
Aborted
(3)slambook2-master/ch5/build/rgbd# ./joinMap
请在有pose.txt的目录下运行此程序
(4)slambook2-master/ch5/build/stereo# ./stereoVision
[ WARN:0@0.001] global /mnt/d/slam14/wsl_libs/opencv-4.x/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('./left.png'): can't open/read file: check file path/integrity
[ WARN:0@0.001] global /mnt/d/slam14/wsl_libs/opencv-4.x/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('./right.png'): can't open/read file: check file path/integrity
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/imgproc/src/median_blur.dispatch.cpp:283: error: (-215:Assertion failed) !_src0.empty() in function 'medianBlur'
Aborted
3.解决方案
(1)将编译生成的imageBasics拷贝到imageBasics源码目录下然后运行./imageBasics结果如下:
slambook2-master/ch5/imageBasics# ./imageBasics
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted
(2)将编译生成的undistortImage拷贝到imageBasics源码目录下然后运行./undistortImage结果如下:
slambook2-master/ch5/imageBasics# ./undistortImage
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
Aborted
(3)将编译生成的joinMap拷贝到rgbd源码目录下然后运行./joinMap如下:
slambook2-master/ch5/rgbd# ./joinMap
转换图像中: 1
转换图像中: 2
转换图像中: 3
转换图像中: 4
转换图像中: 5
点云共有1081843个点.
terminate called after throwing an instance of 'std::runtime_error'
what(): Pangolin X11: Failed to open X display
Aborted
(4)将编译生成的stereoVision拷贝到stereo源码目录下然后运行./stereoVision结果如下:
slambook2-master/ch5/stereo# ./stereoVision
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
Aborted
(1)(2)(4)结果
//TODO有待解决,解决其他问题后一并解决
应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。
slambook2-master/ch6
编译正常,log如下:
slambook2-master/ch6# mkdir build && cd build && cmake .. && make -j16
……
[ 66%] Linking CXX executable ceresCurveFitting
[ 66%] Built target ceresCurveFitting
[ 83%] Linking CXX executable gaussNewton
[ 83%] Built target gaussNewton
[100%] Linking CXX executable g2oCurveFitting
[100%] Built target g2oCurveFitting
slambook2-master/ch6/build# ls
CMakeCache.txt CMakeFiles Makefile ceresCurveFitting cmake_install.cmake g2oCurveFitting gaussNewton
slambook2-master/ch6/build# ./ceresCurveFitting
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 1.597873e+06 0.00e+00 3.52e+06 0.00e+00 0.00e+00 1.00e+04 0 3.41e-05 1.81e-03
1 1.884440e+05 1.41e+06 4.86e+05 9.88e-01 8.82e-01 1.81e+04 1 8.89e-04 2.76e-03
2 1.784821e+04 1.71e+05 6.78e+04 9.89e-01 9.06e-01 3.87e+04 1 1.72e-05 2.80e-03
3 1.099631e+03 1.67e+04 8.58e+03 1.10e+00 9.41e-01 1.16e+05 1 1.41e-05 2.83e-03
4 8.784938e+01 1.01e+03 6.53e+02 1.51e+00 9.67e-01 3.48e+05 1 1.41e-05 2.85e-03
5 5.141230e+01 3.64e+01 2.72e+01 1.13e+00 9.90e-01 1.05e+06 1 1.41e-05 2.88e-03
6 5.096862e+01 4.44e-01 4.27e-01 1.89e-01 9.98e-01 3.14e+06 1 1.29e-05 2.90e-03
7 5.096851e+01 1.10e-04 9.53e-04 2.84e-03 9.99e-01 9.41e+06 1 1.31e-05 2.92e-03
solve time cost = 0.00331742 seconds.
Ceres Solver Report: Iterations: 8, Initial cost: 1.597873e+06, Final cost: 5.096851e+01, Termination: CONVERGENCE
estimated a,b,c = 0.890908 2.1719 0.943628
slambook2-master/ch6/build# ./g2oCurveFitting
start optimization
iteration= 0 chi2= 376785.128234 time= 9.859e-06 cumTime= 9.859e-06 edges= 100 schur= 0
iteration= 1 chi2= 35673.566018 time= 4.188e-06 cumTime= 1.4047e-05 edges= 100 schur= 0
iteration= 2 chi2= 2195.012304 time= 3.737e-06 cumTime= 1.7784e-05 edges= 100 schur= 0
iteration= 3 chi2= 174.853126 time= 3.707e-06 cumTime= 2.1491e-05 edges= 100 schur= 0
iteration= 4 chi2= 102.779695 time= 3.627e-06 cumTime= 2.5118e-05 edges= 100 schur= 0
iteration= 5 chi2= 101.937194 time= 3.657e-06 cumTime= 2.8775e-05 edges= 100 schur= 0
iteration= 6 chi2= 101.937020 time= 3.267e-06 cumTime= 3.2042e-05 edges= 100 schur= 0
iteration= 7 chi2= 101.937020 time= 3.586e-06 cumTime= 3.5628e-05 edges= 100 schur= 0
iteration= 8 chi2= 101.937020 time= 3.216e-06 cumTime= 3.8844e-05 edges= 100 schur= 0
iteration= 9 chi2= 101.937020 time= 3.256e-06 cumTime= 4.21e-05 edges= 100 schur= 0
solve time cost = 0.000277812 seconds.
estimated model: 0.890912 2.1719 0.943629
slambook2-master/ch6/build# ./gaussNewton
total cost: 3.19575e+06, update: 0.0455771 0.078164 -0.985329 estimated params: 2.04558,-0.921836,4.01467
total cost: 376785, update: 0.065762 0.224972 -0.962521 estimated params: 2.11134,-0.696864,3.05215
total cost: 35673.6, update: -0.0670241 0.617616 -0.907497 estimated params: 2.04432,-0.0792484,2.14465
total cost: 2195.01, update: -0.522767 1.19192 -0.756452 estimated params: 1.52155,1.11267,1.3882
total cost: 174.853, update: -0.537502 0.909933 -0.386395 estimated params: 0.984045,2.0226,1.00181
total cost: 102.78, update: -0.0919666 0.147331 -0.0573675 estimated params: 0.892079,2.16994,0.944438
total cost: 101.937, update: -0.00117081 0.00196749 -0.00081055 estimated params: 0.890908,2.1719,0.943628
total cost: 101.937, update: 3.4312e-06 -4.28555e-06 1.08348e-06 estimated params: 0.890912,2.1719,0.943629
total cost: 101.937, update: -2.01204e-08 2.68928e-08 -7.86602e-09 estimated params: 0.890912,2.1719,0.943629
cost: 101.937>= last cost: 101.937, break.
solve time cost = 0.000226313 seconds.
estimated abc = 0.890912, 2.1719, 0.943629
/ch7
1.编译问题
CMake Error at CMakeLists.txt:9 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5
1.解决方案
因为按照了opencv4.5.5版本不是opencv3.x.x版本,将CMakeLists.txt中:
find_package( OpenCV 3 REQUIRED )
改为:
find_package( OpenCV REQUIRED )
2.编译问题
[ 50%] Building CXX object CMakeFiles/pose_estimation_3d3d.dir/pose_estimation_3d3d.cpp.o
/mnt/d/slam14/slambook2-master/ch7/pose_estimation_2d2d.cpp: In function ‘int main(int, char**)’:
/mnt/d/slam14/slambook2-master/ch7/pose_estimation_2d2d.cpp:36:31: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
36 | Mat img_1 = imread(argv[1], CV_LOAD_IMAGE_COLOR);
2.解决方案
在源码orb_cv.cpp、triangulation.cpp、pose_estimation_2d2d.cpp、pose_estimation_3d2d.cpp、pose_estimation_3d3d.cpp中添加头文件
#include <opencv2/imgcodecs/legacy/constants_c.h>
#参考链接
SLAM十四讲,第七章程序ch7报错, error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope_XXX的博客-CSDN博客_cv_load_image_color
3.编译问题
[ 75%] Building CXX object CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o
/mnt/d/slam14/slambook2-master/ch7/pose_estimation_2d2d.cpp: In function ‘void pose_estimation_2d2d(std::vector<cv::KeyPoint>, std::vector<cv::KeyPoint>, std::vector<cv::DMatch>, cv::Mat&, cv::Mat&)’:
/mnt/d/slam14/slambook2-master/ch7/pose_estimation_2d2d.cpp:144:61: error: ‘CV_FM_8POINT’ was not declared in this scope
144 | fundamental_matrix = findFundamentalMat(points1, points2, CV_FM_8POINT);
3.解决方案
将源码/slambook2-master/ch7/pose_estimation_2d2d.cpp中CV_FM_8POINT改为FM_8POINT即可。如下所示:
//fundamental_matrix = findFundamentalMat ( points1, points2, CV_FM_8POINT );
fundamental_matrix = findFundamentalMat ( points1, points2, FM_8POINT );
#参考链接高翔slam14讲中ch7代码中的一些修改_jywell-CSDN博客
4.编译问题
[ 83%] Linking CXX executable pose_estimation_2d2d
In file included from /usr/local/include/g2o/core/base_unary_edge.h:30,
from /mnt/d/slam14/slambook2-master/ch7/pose_estimation_3d2d.cpp:8:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’
199 | struct HessianTupleType<std::index_sequence<Ints...>> {
4.解决方案
在CMakeLists中添加C++14编译
set( CMAKE_CXX_STANDARD 14)
5.编译问题
[ 83%] Linking CXX executable pose_estimation_3d3d
/usr/bin/ld: CMakeFiles/pose_estimation_3d3d.dir/pose_estimation_3d3d.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
pose_estimation_3d3d.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d3d.dir/pose_estimation_3d3d.cpp.o: in function `unsigned long long fmt::v8::detail::precision_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
5.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
add_executable(pose_estimation_3d2d pose_estimation_3d2d.cpp)
target_link_libraries(pose_estimation_3d2d
g2o_core g2o_stuff
${OpenCV_LIBS})
add_executable(pose_estimation_3d3d pose_estimation_3d3d.cpp)
target_link_libraries(pose_estimation_3d3d
g2o_core g2o_stuff
${OpenCV_LIBS})
改为
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)
/ch8
1.编译问题
(1)[ 50%] Building CXX object CMakeFiles/optical_flow.dir/optical_flow.cpp.o
/mnt/d/slam14/slambook2-master/ch8/optical_flow.cpp: In function ‘int main(int, char**)’:
/mnt/d/slam14/slambook2-master/ch8/optical_flow.cpp:145:37: error: ‘CV_GRAY2BGR’ was not declared in this scope
145 | cv::cvtColor(img2, img2_single, CV_GRAY2BGR);
(2)[ 50%] Building CXX object CMakeFiles/direct_method.dir/direct_method.cpp.o
/mnt/d/slam14/slambook2-master/ch8/direct_method.cpp: In function ‘void DirectPoseEstimationSingleLayer(const cv::Mat&, const cv::Mat&, const VecVector2d&, std::vector<double, std::allocator<double> >, Sophus::SE3d&)’:
/mnt/d/slam14/slambook2-master/ch8/direct_method.cpp:206:35: error: ‘CV_GRAY2BGR’ was not declared in this scope
206 | cv::cvtColor(img2, img2_show, CV_GRAY2BGR);
1.解决方案
(1)、(2)这是由于OpenCV版本更新导致的,用COLOR_GRAY2BGR替换掉CV_GRAY2BGR即可。
(2)修改完后会报错:
/mnt/d/slam14/slambook2-master/ch8/direct_method.cpp:206:35: error: ‘COLOR_GRAY2BGR’ was not declared in this scope; did you mean ‘cv::COLOR_GRAY2BGR’?
206 | cv::cvtColor(img2, img2_show, COLOR_GRAY2BGR);
将cv::cvtColor(img2, img2_show, COLOR_GRAY2BGR);
改为cv::cvtColor(img2, img2_show, cv::COLOR_GRAY2BGR);
即可。
2.编译问题
[ 50%] Building CXX object CMakeFiles/direct_method.dir/direct_method.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 /mnt/d/slam14/slambook2-master/ch8/direct_method.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<std::decay_t<P>>::value;
2.解决方案
将CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")注释掉即可
#set(CMAKE_CXX_FLAGS "-std=c++11")
3.编译问题
[ 75%] Linking CXX executable direct_method
/usr/bin/ld: CMakeFiles/direct_method.dir/direct_method.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
direct_method.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/direct_method.dir/direct_method.cpp.o: in function `unsigned long long fmt::v8::detail::precision_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
direct_method.cpp:(.text+0x2e): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
3.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
target_link_libraries(direct_method ${OpenCV_LIBS} ${Pangolin_LIBRARIES})
改为:
target_link_libraries(direct_method ${OpenCV_LIBS} ${Pangolin_LIBRARIES} fmt)
4.编译问题
(1)slambook2-master/ch8# ./direct_method
iteration: 0, cost: 1.26214e+07
iteration: 1, cost: 5.57538e+06
iteration: 2, cost: 2.10167e+06
iteration: 3, cost: 1.55744e+06
cost increased: 1.57708e+06, 1.55744e+06
T21 =
0.999991 0.00226116 0.00368398 -0.00837304
-0.00227106 0.999994 0.00268373 0.000714081
-0.00367789 -0.00269207 0.99999 -0.725078
0 0 0 1
direct method for single layer: 0.00258083
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
Aborted
(2)slambook2-master/ch8# ./optical_flow
build pyramid time: 9.7407e-05
track pyr 3 cost time: 0.000170617
track pyr 2 cost time: 0.000116553
track pyr 1 cost time: 0.000108528
track pyr 0 cost time: 0.000158053
optical flow by gauss-newton: 0.000754244
optical flow by opencv: 0.00101882
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.5-dev) /mnt/d/slam14/wsl_libs/opencv-4.x/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
Aborted
4.解决方案
//TODO有待解决,解决其他问题后一并解决
应该是由于wsl没有安装UI界面,导致编译的程序调用界面显示时不能显示所致。
/ch9
1.编译问题
[ 66%] Building CXX object CMakeFiles/bundle_adjustment_g2o.dir/bundle_adjustment_g2o.cpp.o
In file included from /usr/local/include/ceres/internal/parameter_dims.h:37,
from /usr/local/include/ceres/internal/autodiff.h:151,
from /usr/local/include/ceres/autodiff_cost_function.h:130,
from /usr/local/include/ceres/ceres.h:37,
from /mnt/d/slam14/slambook2-master/ch9/bundle_adjustment_ceres.cpp:2:
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
64 | struct SumImpl<std::integer_sequence<T, N, Ns...>> {
1.解决方案
在CMakeLists中添加set( CMAKE_CXX_STANDARD 14)
2.编译问题
[100%] Linking CXX executable bundle_adjustment_g2o
/usr/bin/ld: CMakeFiles/bundle_adjustment_g2o.dir/bundle_adjustment_g2o.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
bundle_adjustment_g2o.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/bundle_adjustment_g2o.dir/bundle_adjustment_g2o.cpp.o: in function `unsigned long long fmt::v8::detail::precision_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
2.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
target_link_libraries(bundle_adjustment_g2o ${G2O_LIBS} bal_common)
改为:
target_link_libraries(bundle_adjustment_g2o ${G2O_LIBS} bal_common fmt)
/ch10
1.编译问题
[ 50%] Building CXX object CMakeFiles/pose_graph_g2o_lie.dir/pose_graph_g2o_lie_algebra.cpp.o
In file included from /usr/local/include/g2o/core/base_binary_edge.h:30,
from /usr/local/include/g2o/types/slam3d/types_slam3d.h:31,
from /mnt/d/slam14/slambook2-master/ch10/pose_graph_g2o_SE3.cpp:5:
/usr/local/include/g2o/core/base_fixed_sized_edge.h:199:32: error: ‘index_sequence’ is not a member of ‘std’
199 | struct HessianTupleType<std::index_sequence<Ints...>> {
1.解决方案
在CMakeLists中添加C++14编译
set( CMAKE_CXX_STANDARD 14)
2.编译问题
[100%] Linking CXX executable pose_graph_g2o_lie
/usr/bin/ld: CMakeFiles/pose_graph_g2o_lie.dir/pose_graph_g2o_lie_algebra.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
pose_graph_g2o_lie_algebra.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/pose_graph_g2o_lie.dir/pose_graph_g2o_lie_algebra.cpp.o: in function `unsigned long long fmt::v8::detail::precision_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
2.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将CMakeLists.txt中:
target_link_libraries(pose_graph_g2o_lie
g2o_core g2o_stuff
${CHOLMOD_LIBRARIES}
${Sophus_LIBRARIES}
)
改为:
target_link_libraries(pose_graph_g2o_lie
g2o_core g2o_stuff
${CHOLMOD_LIBRARIES}
${Sophus_LIBRARIES}
fmt)
3.编译问题
slambook2-master/ch10/build# ./pose_graph_g2o_lie ../sphere.g2o
Sophus ensure failed in function 'void Sophus::SO3Base<Derived>::normalize() [with Derived = Sophus::SO3<double>]', file '/usr/local/include/sophus/so3.hpp', line 303.
Quaternion ( 0.706662 4.32706e-17 0.707551 -4.3325e-17) should not be close to zero!
Aborted
3.解决方案
在函数virtual bool read(istream& is)中加入return true;
#参考链接视觉SLAM十四讲 第10章 运行pose_graph_g2o_lie时报错_u012464154的博客-CSDN博客
/ch11
1.编译问题
CMake Error at CMakeLists.txt:8 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3.1".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5
1.解决方案
将CMakeLists改为:
# opencv
#find_package( OpenCV 3.1 REQUIRED )
find_package( OpenCV REQUIRED )
2.编译问题
-- Build files have been written to: /mnt/d/slam14/slambook2-master/ch11/build
make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'gen_vocab'. Stop.
make[2]: *** Waiting for unfinished jobs....
make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'loop_closure'. Stop.
make[2]: *** Waiting for unfinished jobs....
make[2]: *** No rule to make target '/usr/local/lib/libDBoW3.a', needed by 'feature_training'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 50%] Building CXX object CMakeFiles/feature_training.dir/feature_training.cpp.o
[ 50%] Building CXX object CMakeFiles/loop_closure.dir/loop_closure.cpp.o
[ 50%] Building CXX object CMakeFiles/gen_vocab.dir/gen_vocab_large.cpp.o
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/feature_training.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/loop_closure.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/gen_vocab.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
2.解决方案
由于/usr/local/lib/中只有libDBoW3.so没有libDBoW3.a,将CMakeLists中libDBoW3.a改为libDBoW3.so即可,如下所示:
#set( DBoW3_LIBS "/usr/local/lib/libDBoW3.a" )
set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" )
#参考链接
make[2]: *** No rule to make target ‘/usr/local/lib/libDBoW3.a‘, needed by ‘feature_training‘. Stop_听雪楼主长恨水的博客-CSDN博客
高翔视觉slam十四讲第二版第十一章DBow3词库安装与出现的问题 - JavaShuo
3.编译问题
slambook2-master/ch11/build# ./gen_vocab
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted
root@LAPTOP-HAUD7VNG:/mnt/d/slam14/slambook2-master/ch11/build# ./loop_closure
reading database
Vocabulary does not exist.
3.解决方案
//TODO有待解决
slambook2-master/ch12
1.编译问题
CMake Error at dense_mono/CMakeLists.txt:11 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3.1".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.5
1.解决方案
将CMakeLists改为:
# opencv
#find_package( OpenCV 3.1 REQUIRED )
find_package( OpenCV REQUIRED )
2.编译问题
[ 50%] Building CXX object dense_mono/CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o
In file included from /usr/local/include/pcl-1.12/pcl/pcl_macros.h:74,
from /usr/local/include/pcl-1.12/pcl/point_cloud.h:50,
from /mnt/d/slam14/slambook2-master/ch12/dense_RGBD/surfel_mapping.cpp:5:
/usr/local/include/pcl-1.12/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
7 | #error PCL requires C++14 or above
| ^~~~~
2.解决方案
在CMakeLists中添加
set( CMAKE_CXX_STANDARD 14)
3.编译问题
/mnt/d/slam14/slambook2-master/ch12/dense_mono/dense_mapping.cpp:460:33: error: ‘CV_GRAY2BGR’ was not declared in this scope
460 | cv::cvtColor(ref, ref_show, CV_GRAY2BGR);
| ^~~~~~~~~~~
3.解决方案
这是由于OpenCV版本更新导致的,用COLOR_GRAY2BGR替换掉CV_GRAY2BGR即可。
4.编译问题
[ 37%] Built target octomap_mapping
/usr/bin/ld: CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o: in function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
dense_mapping.cpp:(.text+0xe): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
/usr/bin/ld: CMakeFiles/dense_mapping.dir/dense_mapping.cpp.o: in function `unsigned long long fmt::v8::detail::precision_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.0]':
dense_mapping.cpp:(.text+0x2e): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
4.解决方案
没有链接fmt库,链接上fmt 库就没问题了,将slambook2-master/ch12/dense_mono/dense_mapping.cpp/CMakeLists.txt中:
target_link_libraries(dense_mapping ${THIRD_PARTY_LIBS})
改为:
target_link_libraries(dense_mapping ${THIRD_PARTY_LIBS} fmt)
5.编译问题
/mnt/d/slam14/slambook2-master/ch12/dense_RGBD/surfel_mapping.cpp:31:9: error: ‘class pcl::MovingLeastSquares<pcl::PointXYZRGB, pcl::PointXYZRGBNormal>’ has no member named ‘setPolynomialFit’; did you mean ‘setPolynomialOrder’’?
31 | mls.setPolynomialFit(polynomial_order > 1);
5.解决方案
surfel_mapping.cpp报错说这个setPolynomialFit函数不是pcl库的成员函数,但是它就是pcl库的成员函数,说明这个pcl库没安装好需要重新安装pcl库。