ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Compiling a melodic project in noetic: catkin_make can't find Python.h

asked 2021-07-15 04:53:07 -0500

The_Vaasty gravatar image

updated 2021-07-19 01:03:05 -0500

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 ...
(more)
edit retag flag offensive close merge delete

Comments

Please don't use links for short text files. Edit your question to include the text, and format each with the 101010 button.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-17 09:34:30 -0500 )edit

Edited the question per the instructions.

The_Vaasty gravatar image The_Vaasty  ( 2021-07-19 01:03:37 -0500 )edit

Thanks. This help people who see the question in the future.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-19 09:20:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-19 09:19:17 -0500

Mike Scheutzow gravatar image

updated 2021-07-19 09:22:29 -0500

find_package(Python COMPONENTS Interpreter Development)

According to cmake.org, this should be "Python3". If your cmake version is earlier than 3.12, there's a workaround using pkgconfig. This assumes you have the apt package python3-dev installed.

edit flag offensive delete link more

Comments

Thanks, but it didn't help. Still throws the same error. I have Cmake 3.16.3 and python3-dev installed.

The_Vaasty gravatar image The_Vaasty  ( 2021-07-20 02:19:04 -0500 )edit
1

Did you first clean up by deleting the top-level devel and build dirs in catkin_ws dir ?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-20 07:40:30 -0500 )edit

According to the page I linked to, the var name is "Python3_INCLUDE_DIRS". Also look at the boxed "Note" on that page -- it's unclear to me if you can declare both Intepreter and Development at the same time.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-20 07:49:59 -0500 )edit

Sorry for the late answer. It works now. I had the var name all in capitals. Thanks for the help.

The_Vaasty gravatar image The_Vaasty  ( 2021-07-23 08:44:30 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-07-15 04:53:07 -0500

Seen: 695 times

Last updated: Jul 19 '21