ros-mpu9150: CMakeLists.txt undefined reference
Hi,
I'm trying create a ROS node that publishes the InvenSense MPU-9150 data into a Topic. I'm using the userspace driver linux-mpu9150.
Here's the file structure of the package:
├── CMakeLists.txt
├── cscope.out
├── include
├── LICENSE
├── package.xml
├── README.md
└── src
├── linux-mpu9150
│ ├── eMPL
│ │ ├── dmpKey.h
│ │ ├── dmpmap.h
│ │ ├── inv_mpu.c
│ │ ├── inv_mpu_dmp_motion_driver.c
│ │ ├── inv_mpu_dmp_motion_driver.h
│ │ ├── inv_mpu.h
│ │ └── README.md
│ ├── glue
│ │ ├── linux_glue.c
│ │ └── linux_glue.h
│ ├── imu.c
│ ├── imucal.c
│ ├── LICENSE
│ ├── local_defaults.h
│ ├── Makefile-cross
│ ├── Makefile-native
│ ├── mpu9150
│ │ ├── mpu9150.c
│ │ ├── mpu9150.h
│ │ ├── quaternion.c
│ │ ├── quaternion.h
│ │ ├── vector3d.c
│ │ └── vector3d.h
│ └── README.md
├── mpu9150_node.cpp
└── random.cpp
My CMakeLists.txt:
project(ros_mpu9150)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES mpu9150
# CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
## Alternatively we can use the CMakeLists.txt of the subdirs
#add_subdirectory(src/linux-mpu9150)
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
src/linux-mpu9150
src/linux-mpu9150/eMPL
src/linux-mpu9150/glue
src/linux-mpu9150/mpu9150
)
#link_directories()
# Test to verify simple ROS node
add_executable(random src/random.cpp)
target_link_libraries(random ${catkin_LIBRARIES} )
# The MPU9150 node
# Adds flags to the compiler command line for sources in the current directory and below.
add_definitions(-DEMPL_TARGET_LINUX -DMPU9150 -DAK8975_SECONDARY)
add_executable(mpu9150_node src/mpu9150_node.cpp)
add_library(mpu9150 SHARED src/linux-mpu9150/mpu9150/mpu9150.h src/linux-mpu9150/mpu9150/mpu9150.c)
add_library(quaternion SHARED src/linux-mpu9150/mpu9150/quaternion.h src/linux-mpu9150/mpu9150/quaternion.c)
add_library(vector3d SHARED src/linux-mpu9150/mpu9150/vector3d.h src/linux-mpu9150/mpu9150/vector3d.c)
add_library(inv_mpu SHARED src/linux-mpu9150/eMPL/inv_mpu.h src/linux-mpu9150/eMPL/inv_mpu.c)
add_library(inv_mpu_dmp_motion_driver SHARED src/linux-mpu9150/eMPL/inv_mpu_dmp_motion_driver.h src/linux-mpu9150/eMPL/inv_mpu_dmp_motion_driver.c)
add_library(linux_glue SHARED src/linux-mpu9150/glue/linux_glue.h src/linux-mpu9150/glue/linux_glue.c)
target_link_libraries(mpu9150_node mpu9150 inv_mpu quaternion linux_glue inv_mpu_dmp_motion_driver vector3d ${catkin_LIBRARIES})
#target_link_libraries(mpu9150_node ${catkin_LIBRARIES})
And what i got when i execute catkin_make
:
####
#### Running command: "make -j4 -l4" in "/home/victor/catkin_ws/build"
####
[ 12%] Built target beginner_tutorials_gencpp
[ 25%] Built target beginner_tutorials_genlisp
[ 50%] Built target beginner_tutorials_genpy
[ 56%] Built target inv_mpu
[ 62%] [ 68%] Built target inv_mpu_dmp_motion_driver
Built target linux_glue
[ 75%] Built target mpu9150
[ 81%] [ 87%] Built target random
Built target quaternion
[ 93%] Scanning dependencies of target mpu9150_node
Built target vector3d
[100%] Building CXX object ros_mpu9150/CMakeFiles/mpu9150_node.dir/src/mpu9150_node.cpp.o
Linking CXX executable /home/victor/catkin_ws/devel/lib/ros_mpu9150/mpu9150_node
CMakeFiles/mpu9150_node.dir/src/mpu9150_node.cpp.o: In function `main':
mpu9150_node.cpp:(.text+0x176): undefined reference to `mpu9150_set_debug(int)'
mpu9150_node.cpp:(.text+0x18f): undefined reference to `mpu9150_init(int, int, int)'
mpu9150_node.cpp:(.text+0x244): undefined reference to `linux_delay_ms(unsigned long)'
mpu9150_node.cpp:(.text+0x28f): undefined reference to `mpu9150_read(mpudata_t*)'
mpu9150_node.cpp:(.text+0x4b5): undefined reference to `linux_delay_ms(unsigned long)'
CMakeFiles/mpu9150_node.dir/src/mpu9150_node.cpp.o: In function `set_cal(int, char*)':
mpu9150_node.cpp:(.text+0x97e): undefined reference to `mpu9150_set_mag_cal(caldata_t*)'
mpu9150_node.cpp:(.text+0x98b): undefined reference to `mpu9150_set_accel_cal(caldata_t*)'
collect2: ld devolvió el estado de salida 1
make[2]: *** [/home/victor/catkin_ws/devel/lib/ros_mpu9150/mpu9150_node] Error 1
make[1]: *** [ros_mpu9150/CMakeFiles/mpu9150_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
These undefined reference ...