ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

main doesn't find the functions in the header file

asked 2021-12-05 07:55:27 -0600

v.leto gravatar image

Hi! I would like to create a header file, but when I do catkin_make, it doesn't find the functions in the header file. I think that the problem is in my CMaleLists.txt. Do I have to add something else? thank you image description

cmake_minimum_required(VERSION 2.8.3)
project(immagine)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS

  roscpp
  rospy
  std_msgs
  marta_msgs
  geometry_msgs
  message_generation
  sensor_msgs
  auv_lib
  genmsg
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
find_package(cmake_modules REQUIRED)
find_package(Eigen REQUIRED)
## Generate added messages and services with any dependencies listed here
generate_messages(
   DEPENDENCIES
   std_msgs
   marta_msgs
 )


## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
#  INCLUDE_DIRS include

#  LIBRARIES immagine
CATKIN_DEPENDS   roscpp rospy std_msgs marta_msgs message_runtime auv_lib 
#  DEPENDS system_lib
)

###########
## Build ##
###########

if(NOT DEFINED CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
    endif()

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Eigen_INCLUDE_DIRS}
)


 ## Declare a C++ library
    # add_library(${PROJECT_NAME}
#   src/${PROJECT_NAME}/immagine.cpp
# )
add_library(immagine src/funzioni.cpp)



 ## Declare a C++ executable
    ## With catkin_make all packages are built within a single CMake context
    ## The recommended prefix ensures that target names across packages don't collide
    add_executable(gestisco_dati src/gestisco_dati.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(gestisco_dati ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
target_link_libraries(gestisco_dati ${catkin_LIBRARIES})
edit retag flag offensive close merge delete

Comments

Do you get an error? if so can you post the error please.

osilva gravatar image osilva  ( 2021-12-05 08:22:54 -0600 )edit

Please also post your source code.

Geoff gravatar image Geoff  ( 2021-12-05 17:01:45 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-12-05 17:55:07 -0600

miura gravatar image

Maybe you are not linking the library you created below.

add_library(immagine src/funzioni.cpp)

target_link_libraries(gestisco_dati ${catkin_LIBRARIES})

Changing the above to the following may solve the problem.

target_link_libraries(gestisco_dati immagine ${catkin_LIBRARIES})
edit flag offensive delete link more

Comments

1

thank you!

v.leto gravatar image v.leto  ( 2021-12-06 02:50:52 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-12-05 07:55:27 -0600

Seen: 180 times

Last updated: Dec 05 '21