问题来源于libtorch中的Python_header.h
在C++代码下,ROS1 kinetic版本环境中,使用libtorch库编译时出现如下问题
if PY_MAJOR_VERSION < 3
error "Python 2 has reached end-of-life and is no longer supported by PyTorch."
endif
主要时因为ROS1 kinetic默认使用/usr/bin/python2。
参考链接:https://blog.csdn.net/weixin_39640414/article/details/111445084
执行catkin_make后,显示
catkin_make -DPYTHON_EXECUTABLE=/home/lufeng/anaconda3/bin/python -DPYTHON_INCLUDE_DIR=/home/lufeng/anaconda3/include/python3.7m -DPYTHON_LIBRARY=/home/lufeng/anaconda3/lib/libpython3.7m.so
并注释Python_header.h中对python版本的检验。
修改后编译器指向python3,编译通过。