之前由于ros、python、pip这些工具的版本和冲突问题,在16.04上一直装不好pip,和python的一些库,然后装了annaconda3,轻松解决了python库问题。然而引发了一系列编译问题,annaconda也会搞一个系统环境,编译的时候经常会链接到annaconda3的环境而不是系统原有环境。之前解决参考:https://blog.csdn.net/qq_29572513/article/details/88742652
上面的博客确实是一个解决办法,特别是一些系统底层库出问题的时候,但是编译rtabmap的时候遇到qt5的库链接不正常,经查发现按拿出哦你打的库是qt5.9版本,而系统的是qt5.5版本,如何切换呢,qt的库非常多,不可能直接将系统的全部copy到conda3里面吧。
还有个问题,一直不知道为什么按照conda3后,cmake和catkin_make的链接路径会改变,在windows是很容易设置库的编译和链接路径的。但是在ubuntu,暂时不知道怎么弄。
为解决rtabmap qt5的链接问题,在make的时候发现是qt5的哭链接异常
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::QSvgGenerator()@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::~QSvgGenerator()@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::setViewBox(QRect const&)@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::setDescription(QString const&)@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::setSize(QSize const&)@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::setFileName(QString const&)@Qt_5'
../../../bin/librtabmap_gui.so.0.20.7: undefined reference to `QSvgGenerator::setTitle(QString const&)@Qt_5'
于是考虑到cmake的时候应该会有相关库配置的信息,最终在CMakeCache.txt找到qt5指定路径部分使用了annaconda3的环境,将它们改为系统路径即可。
//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Core
//The directory containing a CMake configuration file for Qt5Gui.
Qt5Gui_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Gui
//The directory containing a CMake configuration file for Qt5Network.
Qt5Network_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Network
//The directory containing a CMake configuration file for Qt5PrintSupport.
Qt5PrintSupport_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5PrintSupport
//The directory containing a CMake configuration file for Qt5Svg.
Qt5Svg_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Svg
//The directory containing a CMake configuration file for Qt5WebKit.
Qt5WebKit_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5WebKit
//The directory containing a CMake configuration file for Qt5.
Qt5_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5
该方法解决的是工程直接链接的库的问题,解决不了类似qt5本身再链接其他库的问题。而且每次cmake后都要修改此文件。要是能直接修改cmake指定的链接文件就好了,有待探索。