Hi @neilthomas110,
Your logs say that in compiling moveit2_scripts, there is a main function missing.
You showed the content of cartesian_path.cpp that has a main function, and that is correct.
But let’s look at the error more carefully, especially the following line:
gmake[2]: *** [CMakeFiles/test_trajectory.dir/build.make:351: test_trajectory] Error 1
As you can see, the error mentions test_trajectory.
In your CMakeLists.txt you have 4 calls to add_executable:
- add_executable(test_trajectory src/test_trajectory.cpp)
- add_executable(test_trajectory2 src/test_trajectory2.cpp)
- add_executable(test_trajectory3 src/test_trajectory3.cpp)
- add_executable(cartesian_path src/cartesian_path.cpp)
We can see that the test_trajectory in the CMakeLists.txt refers to test_trajectory.cpp, not the file that you think the error is, since the name of the executable for cartesian_path.cpp is cartesian_path, not test_trajectory as stated in the error.
So, the problem is on test_trajectory.cpp, not on cartesian_path.cpp.
I suppose this file does not have a main function.
You can also find the compiled executables using the following command, to make sure the error is not building the cartesian_path executable:
ls ~/ros2_ws/build/moveit2_scripts/
with the command above you should see that the 3 other executables compiled fine:
- cartesian_path, test_trajectory2, test_trajectory3
The easy ways of getting rid of this error are two:
- Add a main function to the test_trajectory.cpp file
- Comment out the lines that refer to that file on the
CMakeLists.txt
.
If we choose the second option, the CMakeLists.txt
would be like below:
cmake_minimum_required(VERSION 3.8)
project(moveit2_scripts)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(moveit_core REQUIRED)
find_package(moveit_ros_planning REQUIRED)
find_package(moveit_ros_planning_interface REQUIRED)
find_package(interactive_markers REQUIRED)
find_package(geometric_shapes REQUIRED)
find_package(control_msgs REQUIRED)
find_package(moveit_msgs REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# The following line skips the linter which checks for copyrights
# Comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# The following line skips cpplint (only works in a git repo)
# Comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
# Generate the executables
#add_executable(test_trajectory src/test_trajectory.cpp)
#target_include_directories(test_trajectory PUBLIC include)
#ament_target_dependencies(test_trajectory
# ament_cmake
# rclcpp
# rclcpp_action
# moveit_core
# moveit_ros_planning_interface
# interactive_markers
# moveit_ros_planning
# control_msgs
#)
add_executable(test_trajectory2 src/test_trajectory2.cpp)
target_include_directories(test_trajectory2 PUBLIC include)
ament_target_dependencies(test_trajectory2
ament_cmake
rclcpp
rclcpp_action
moveit_core
moveit_ros_planning_interface
interactive_markers
moveit_ros_planning
control_msgs
)
add_executable(test_trajectory3 src/test_trajectory3.cpp)
target_include_directories(test_trajectory3 PUBLIC include)
ament_target_dependencies(test_trajectory3
ament_cmake
rclcpp
rclcpp_action
moveit_core
moveit_ros_planning_interface
interactive_markers
moveit_ros_planning
control_msgs
)
add_executable(cartesian_path src/cartesian_path.cpp)
target_include_directories(cartesian_path PUBLIC include)
ament_target_dependencies(cartesian_path
ament_cmake
rclcpp
rclcpp_action
moveit_core
moveit_ros_planning_interface
interactive_markers
moveit_ros_planning
control_msgs
)
# Install the executables
install(TARGETS
# test_trajectory
test_trajectory2
test_trajectory3
cartesian_path
DESTINATION lib/${PROJECT_NAME}
)
# Install the launch files
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
ament_package()
We basically commented out references to test_trajectory.
Using this modified CMakeLists.txt, you should have no errors compiling your workspace.
Please let us know when you successfully compile your workspace with no errors.