Apollo代码提取移植错误提示总结

1. protobuf的安装及proto文件的编译

2. [undefined reference to testing::internal::xxx in gtest]

未安装gtest模块,可安装此模块或者屏蔽test测试代码
或者安装gtest后,在CmakLists.txt 中加入gtest链接

target_link_libraries(
 ${PROJECT_NAME}
 ...
 gtest
)

3. fLB::FLAGS_xxx’未定义的引用

  • 1)对应的gflags未找到
    参看这篇文章https://blog.csdn.net/cn_wk/article/details/61198182中,gflags的使用方法,找到对应的flag定义文件,将其一起编译
  • 2) CMakeLists.txt 添加gflags链接
find_package(gflags REQUIRED)
...
target_link_libraries(
 ${PROJECT_NAME}
 ...
 gflags
)

4. 对‘google::base::CheckOpMessageBuilder::NewString()’未定义的引用

5. 运行时崩溃,Segmentation fault of google::protobuf::Arena::OnArenaAllocation

应是由于protobuf版本混乱导致,可使用ldd查看是否依赖两个版本的protobuf库,
可参考https://github.com/protocolbuffers/protobuf/issues/4723

6. 对‘apollo::hdmap::LaneInfo::GetProjection(apollo::common::math::Vec2d const&, double, double) const’未定义的引用

  • 1) 应是其他模块对HDmap模块的调用产生的,产生了交叉引用,一般是由于编译test文件而导致的,可以将test文件从编译文件中剔除

  • 2) 出现未定义的引用时,还有可能是link时库的顺序影响,尽量保持库的顺序为底层库在前

7. 对‘qpOASES::QProblemB::getPrimalSolution(double*) const’未定义的引用

添加链接依赖项 qpOASES
首先下载并编译qpOASES,加入环境变量,然后添加链接依赖项

target_link_libraries(
 ${PROJECT_NAME}
 ...
 qpOASES
)

8. 对‘tinyxml2::XMLNode::NextSiblingElement(char const*) const’未定义的引用

target_link_libraries(
 ${PROJECT_NAME}
 ...
 tinyxml2
)

9. 对‘pj_free’未定义的引用

target_link_libraries(
 ${PROJECT_NAME}
 ...
 proj
)

10. warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]

error: inlining failed in call to always_inline ‘__m256 _mm256_setzero_ps()’: target specific option

insert this line to CMakeLists.txt

add_compile_options(-march=native)

11. fatal error: Eigen/Core: 没有那个文件或目录

find_package(Eigen3 REQUIRED)
...
include_directories(
  ${EIGEN3_INCLUDE_DIRS}
  ...
)
...
target_link_libraries(${PROJECT_NAME}
  ${EIGEN3_LIBRARIES}
  ...
)

12. error: ‘__s_getMD5Sum’ is not a member of ‘xxx::xxx::xxx’

添加头文件支持

#include "modules/xxx/proto/xxx.ros.h"

13. fatal error: ros/include/ros/ros.h: 没有那个文件或目录

修改
#include "ros/include/ros/ros.h"
为
#include "ros/ros.h"

14. 对‘xxx’未定义的引用

Reference lib
glfwGetWindowUserPointer glfw
YAML yaml-cpp
  • 对‘pcl::PCLBase::initCompute()’未定义的引用
perception_common

15. libgtest.a(gtest-all.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

/usr/local/lib/libgtest.a: 无法添加符号: 错误的值
参考:https://github.com/google/googletest/issues/854
重新编译安装googletest

cd 
git clone https://github.com/google/googletest.git
vim CMakeLists.txt  
// add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
mkdir build
cd build
cmake ..
make -j12
sudo make install

99. 支持

1) glog gfalgs
参考
https://www.cnblogs.com/burningTheStar/p/6986048.html
2) curlpp

  1. leveldb
  • /# git clone https://github.com/google/leveldb.git
  • /# cp -r leveldb/include/leveldb /usr/include

sudo apt install libleveldb-dev
4)protobuf-3.6.1

https://blog.csdn.net/datase/article/details/82347834
安装完成之后,记得头文件拷贝
sudo cp src/google/protobuf/stubs/*.h /usr/local/protobuf/include/google/protobuf/stubs/
5) qpOASES-3.2.1

你可能感兴趣的:(Apollo代码提取移植错误提示总结)