I want to link my project with the dynamic library "aravis" in the CMakeLists.txt file, but it always fails

628 views Asked by At

Although I tried some methods, all the libraries involved in my project were not linked, even the most basic rclcpp library.

And there is also the problem that the header file cannot be found in vscode, although I think I have given the path to the header file in CMake and the .so file, but there is still no way to solve the problem.

cmake_minimum_required(VERSION 3.5)
project(camera_aravis)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()



INCLUDE_DIRECTORIES(/usr/local/include/aravis-0.8 
/home/nian/Documents/Dep/glib-2.45.2/glib
/home/nian/Documents/Dep/glib-2.45.2
/home/nian/Documents/Dep/glib-2.45.2/gmodule
/opt/ros/foxy/include
/home/nian/Documents/Dep/xmlrpcpp-master/include/xmlrpcpp
/home/nian/Documents/Dep/xmlrpcpp-master/include

)
LINK_DIRECTORIES(/usr/lib /home/nian/Documents/Dep/glib-2.45.2/glib
)
ADD_EXECUTABLE(camnode src/new.cpp)
TARGET_LINK_LIBRARIES(camnode libaravis-0.8.so libglib-2.0.so libgio-2.0.so
libgobject-2.0.so)
    
include_directories(
 include_directories
 ${fcl_INCLUDE_DIRS}
)


# find other ROS2 packages
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(camera_info_manager REQUIRED)
find_package(image_transport REQUIRED)
                                                                                                                                          
add_executable(test_params_rclcpp src/new.cpp)
ament_target_dependencies(test_params_rclcpp
rclcpp
rclcpp_components
sensor_msgs
std_msgs
camera_info_manager
image_transport
camera_calibration_parsers)

install(TARGETS
  test_params_rclcpp
  DESTINATION lib/${PROJECT_NAME}
)

add_executable(camera_param_edit src/new.cpp)
ament_target_dependencies(camera_param_edit 
rclcpp
rclcpp_components
sensor_msgs
std_msgs
camera_info_manager
image_transport
camera_calibration_parsers)

install(TARGETS
  camera_param_edit
  DESTINATION lib/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

This is my CMakeLists, but the error in the terminal is always "undefined reference to".

How can I solve this?

Below is part of my error messagea lot of errors about function references in the library

0

There are 0 answers