Compiling a melodic project in noetic: catkin_make can't find Python.h
Hi, I'm taking over a project that was developed by a fellow student for his diploma thesis. I've received the project files but I can't get the project to compile. It's not a vast project, with only three packages and only a few dependencies. But it was developed under ROS melodic and I'm using noetic. I've checked all dependencies and there shouldn't be any issue. The only issue is a C++ library matplotlibcpp.h used to plot data. It requires the header file "Python.h" and that's the stumbling block. When I try to compile the project using catkin_make, I get the following error:
In file included from /home/jan/roboweld_ws/src/roboweld/planner/src/planner/graph_plotter.cpp:6: /home/jan/roboweld_ws/src/roboweld/planner/include/planner/matplotlibcpp.h:5:10: fatal error: Python.h: No such file or directory
I have asked another colleague, who worked on the project and she said, she was able to compile it under melodic. I know melodic uses Python 2 and noetic Python 3, but the library states it's compatible with both. I've checked /usr/include/python3.8 and the header file is there. VS Code also recognizes the header file. I'm led to believe that the issue lies with the CMakeLists.txt file. I tried to modify it, explicitly including Python directories, but that didn't help either. This is the original CMakeLists:
cmake_minimum_required(VERSION 3.1.3)
project(planner)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(catkin REQUIRED COMPONENTS
rospy
roscpp
std_msgs
interactive_markers
moveit_core
moveit_ros_planning
moveit_ros_planning_interface
moveit_ros_perception
rviz_visual_tools
moveit_visual_tools
pluginlib
pcl_ros
pcl_conversions
rosbag
tf2_ros
tf2_eigen
tf2_geometry_msgs
geometric_shapes
)
find_package(ompl)
find_package(Ceres REQUIRED)
# find_package(sciplot REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED system filesystem date_time thread)
set(THIS_PACKAGE_INCLUDE_DIRS
doc/interactivity/include
)
catkin_package(
LIBRARIES
INCLUDE_DIRS
CATKIN_DEPENDS
moveit_core
moveit_visual_tools
moveit_ros_planning_interface
interactive_markers
tf2_geometry_msgs
DEPENDS
EIGEN3
geometric_shapes
ompl
)
###########
## Build ##
###########
include_directories(
include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
add_library(${PROJECT_NAME}_utils
src/${PROJECT_NAME}/utils.cpp
)
target_link_libraries(${PROJECT_NAME}_utils
${catkin_LIBRARIES}
)
add_library(${PROJECT_NAME}_OmplPlanner
src/${PROJECT_NAME}/OmplPlanner.cpp
src/${PROJECT_NAME}/utils.cpp
)
target_link_libraries(${PROJECT_NAME}_OmplPlanner
${catkin_LIBRARIES}
Ceres::ceres
# sciplot::sciplot
)
add_library(${PROJECT_NAME}_graph_plotter
src/${PROJECT_NAME}/graph_plotter.cpp
)
target_link_libraries(${PROJECT_NAME}_graph_plotter
${catkin_LIBRARIES}
)
add_library(${PROJECT_NAME}_CeresOpt
src/${PROJECT_NAME}/CeresOpt.cpp
src/${PROJECT_NAME}/utils.cpp
)
target_link_libraries(${PROJECT_NAME}_CeresOpt
${catkin_LIBRARIES}
Ceres::ceres
)
include_directories(${THIS_PACKAGE_INCLUDE_DIRS})
include_directories(SYSTEM
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIRS}
${OMPL_INCLUDE_DIRS}
)
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
add_executable(approach_outside_lower_weld src/approach_outside_lower_weld.cpp)
target_link_libraries(approach_outside_lower_weld
${PROJECT_NAME}_utils
${PROJECT_NAME}_OmplPlanner
${PROJECT_NAME}_graph_plotter
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OMPL_LIBRARIES}
)
install(TARGETS approach_outside_lower_weld DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
add_executable(approach_rib_weld src/approach_rib_weld.cpp)
target_link_libraries(approach_rib_weld
${PROJECT_NAME}_utils
${PROJECT_NAME}_OmplPlanner
${PROJECT_NAME}_graph_plotter
${PROJECT_NAME}_CeresOpt
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OMPL_LIBRARIES}
)
install(TARGETS approach_rib_weld DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
add_executable(rib_weld src/rib_weld.cpp)
target_link_libraries(rib_weld
${PROJECT_NAME}_utils
${PROJECT_NAME}_OmplPlanner
${PROJECT_NAME}_graph_plotter
${PROJECT_NAME}_CeresOpt
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OMPL_LIBRARIES}
)
install(TARGETS rib_weld DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
add_executable(outside_lower_weld src/outside_lower_weld.cpp)
target_link_libraries(outside_lower_weld
${PROJECT_NAME}_utils
${PROJECT_NAME}_OmplPlanner
${PROJECT_NAME}_graph_plotter
${PROJECT_NAME}_CeresOpt
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OMPL_LIBRARIES}
)
install(TARGETS outside_lower_weld DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
and this is the one modified by me:
cmake_minimum_required(VERSION 3.1.3)
project(planner)
set(CMAKE_CXX_STANDARD 14 ...
Please don't use links for short text files. Edit your question to include the text, and format each with the 101010 button.
Edited the question per the instructions.
Thanks. This help people who see the question in the future.