【ubuntu20.04+catrographer】衰仔踩坑记录

1 cere-solver版本应为1.4.0

这很重要!
如果你在报错信息中有看到cere,不用怀疑,就是它出了问题。
查看cere-solover版本:
打开home下安装ceres-solver的文件夹,然后打开ceres-solverpackage.xml文件,在里面第33行,可以看到版本号。
推荐博客:
https://blog.csdn.net/YiYeZhiNian/article/details/128805509

2 最后的链结失败: bad value

报错信息如下:

/usr/bin/ld: /usr/local/lib/libprotobuf.a(arena.o): relocation R_X86_64_TPOFF32 against symbol `_ZN6google8protobuf8internal9ArenaImpl13thread_cache_E' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(common.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: bad value
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
<== Failed to process package 'cartographer_rviz': 
  Command '['/home/liujun/example_ws/catrographer_ws/install_isolated/env.sh', 'ninja', '-j8', '-l8']' returned non-zero exit status 1.

Reproduce this error by running:
==> cd /home/liujun/example_ws/catrographer_ws/build_isolated/cartographer_rviz && /home/liujun/example_ws/catrographer_ws/install_isolated/env.sh ninja -j8 -l8

Command failed, exiting.

so动态库编译加上了-fPIC选项 但在链接 libprotobuf.a时, libprotobuf.a的编译未加入-fPIC选项,所以需要 重新编译libprotobuf 并加入 -fPIC选项。

sudo make clean
sudo make uninstall
./configure CXXFLAGS=-fPIC
make
make install

参考博客:
https://blog.csdn.net/whatday/article/details/122553195
https://blog.csdn.net/qq_41005689/article/details/122728281
输入

which protoc

查看protoc路径输出如下:

/bin/protoc /usr/bin/protoc

使用如下命令建立软链接:

sudo ln -s /usr/local/bin/protoc /usr/bin/protoc

其他错误很容易在其他博客找寻到,甚至可以自行解决,相信你可以的。
最后,祝顺利!!!

猜你喜欢

转载自blog.csdn.net/U202113837/article/details/132522582
今日推荐