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

add library to new package

asked 2016-11-02 08:00:00 -0500

sayed gravatar image

updated 2016-11-04 07:07:06 -0500

mgruhler gravatar image

im working on mpu6050 package, i have a library which is work well outside ROS, but i have a problem to make the package, i wrote a node and i added the headers an and the cpp files to include directory in my package , when i do catkin_make, the node can't see the headers , thats what i got:

/home/ahmed/catkin_ws/src/mpu6050/src/mpu6050_node.cpp:12:21: fatal error: mpu6050.h: No such file or directory
compilation terminated.
mpu6050/CMakeFiles/mpu6050_node.dir/build.make:62: recipe for target 'mpu6050/CMakeFiles/mpu6050_node.dir/src/mpu6050_node.cpp.o' failed
make[2]: *** [mpu6050/CMakeFiles/mpu6050_node.dir/src/mpu6050_node.cpp.o] Error 1
CMakeFiles/Makefile2:379: recipe for target 'mpu6050/CMakeFiles/mpu6050_node.dir/all' failed
make[1]: *** [mpu6050/CMakeFiles/mpu6050_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

i did changes to my CMakeList.txt as questions before me but nothing happened

any ideas ?? thank u in advance.


CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(mpu6050)

find_package(catkin REQUIRED COMPONENTS rosconsole roscpp rospy sensor_msgs std_msgs)

catkin_package( INCLUDE_DIRS include LIBRARIES mpu6050 CATKIN_DEPENDS rosconsole roscpp rospy sensor_msgs std_msgs )

include_directories(include ${catkin_INCLUDE_DIRS} src/mpu6050/include/mpu6050 )

add_library(mpu6050 include/${PROJECT_NAME}/mpu6050.cpp include/${PROJECT_NAME}/I2Cdev.cpp ) 

add_executable(mpu6050_node src/mpu6050/src/mpu6050_node.cpp )
add_dependencies(mpu6050_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 

target_link_libraries(mpu6050_node ${catkin_LIBRARIES} )

install(TARGETS mpu6050 mpu6050_node
    ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/ 
    DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
    FILES_MATCHING PATTERN "*.h"
)
edit retag flag offensive close merge delete

Comments

2

maybe post your CMakeLists then?

mgruhler gravatar image mgruhler  ( 2016-11-02 10:43:49 -0500 )edit

Don't post edits as answers. There is an edit button below you question. Use the formatted text button for code (the one with 1s and 0s).

mgruhler gravatar image mgruhler  ( 2016-11-04 07:07:47 -0500 )edit

Can you link to github or whatever hoster? This would make live easier.

Otherwise: Post the line where you include the file, as well as the layout of your package (which file is where). Where is the mpu6050.h located?

Please edit your question

mgruhler gravatar image mgruhler  ( 2016-11-04 07:09:38 -0500 )edit

i'll link it. mpu6050.h is in include directory

sayed gravatar image sayed  ( 2016-11-04 08:27:08 -0500 )edit
sayed gravatar image sayed  ( 2016-11-04 09:02:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-11-04 09:13:29 -0500

mgruhler gravatar image

Well, your workspace setup is crooked (at least to the CMakeLists.txt and we do have nothing else).

I see the following paths:

  • src/mpu6050/include/mpu6050 -> this seems like include files, but they are in src?
  • include/mpu6050 -> but there are .cpp files?
  • src/mpu6050/src/mpu6050_node.cpp -> this is the file with the error
  • include -> this is where you say the mpu6050.h is?

And this is all in the following directory: /home/ahmed/catkin_ws/src/mpu6050/src/mpu6050_node.cpp?

So my next question is: Where is your CMakeLists.txt? It seems to me you have the CMakeLists.txt directly in catkin_ws which is just wrong.

Best put the full workspace on github, not only the CMakeLists.txt so that we can try to reproduce.

edit flag offensive delete link more

Comments

thankx for replying ,, i'll put the ws on git hub, i dont use it much, it'll take a while

sayed gravatar image sayed  ( 2016-11-04 09:42:07 -0500 )edit

https://github.com/AhmedElsayedHamoud...

this is the whole WS .. i hope u reply and help me .. thankx in advance

sayed gravatar image sayed  ( 2016-11-05 11:07:36 -0500 )edit

in this link, the last version of CMakeList, after catkin_make, ros can read the mpu6050.h but it said that it has no members "the methods" like that iam using in the node file

sayed gravatar image sayed  ( 2016-11-05 11:23:17 -0500 )edit

i guess the linking is good, but something wrong with my libraries

sayed gravatar image sayed  ( 2016-11-05 11:35:05 -0500 )edit

Question Tools

Stats

Asked: 2016-11-02 08:00:00 -0500

Seen: 537 times

Last updated: Nov 04 '16