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

Issues linking LabJack Libraries

asked 2014-07-10 10:13:21 -0600

samv03 gravatar image

Hey guys, just to start off with I just started learning ROS this summer so I am a total noob. I just got a LabJack U6-PRO and I am trying to integrate it into a ros project I have been working on but I have been struggling for days. I believe my issue is just getting the library to link correctly from the errors I am getting:

CMakeFiles/serial.dir/src/u6.c.o: In function `openUSBConnection':
u6.c:(.text+0x202): undefined reference to `LJUSB_GetDevCount'
u6.c:(.text+0x23f): undefined reference to `LJUSB_OpenDevice'
u6.c:(.text+0x2b5): undefined reference to `LJUSB_Write'
u6.c:(.text+0x2d7): undefined reference to `LJUSB_Read'
u6.c:(.text+0x3b4): undefined reference to `LJUSB_CloseDevice'
CMakeFiles/serial.dir/src/u6.c.o: In function `closeUSBConnection':
u6.c:(.text+0x42c): undefined reference to `LJUSB_CloseDevice'
CMakeFiles/serial.dir/src/u6.c.o: In function `getCalibrationInfo':
u6.c:(.text+0x5ad): undefined reference to `LJUSB_Write'
u6.c:(.text+0x5e9): undefined reference to `LJUSB_Read'
u6.c:(.text+0x6b2): undefined reference to `LJUSB_Write'
u6.c:(.text+0x6ee): undefined reference to `LJUSB_Read'
CMakeFiles/serial.dir/src/u6.c.o: In function `I2C':
u6.c:(.text+0x11f9): undefined reference to `LJUSB_Write'
u6.c:(.text+0x1245): undefined reference to `LJUSB_Read'
CMakeFiles/serial.dir/src/u6.c.o: In function `ehConfigIO':
u6.c:(.text+0x2429): undefined reference to `LJUSB_Write'
u6.c:(.text+0x2472): undefined reference to `LJUSB_Read'
CMakeFiles/serial.dir/src/u6.c.o: In function `ehConfigTimerClock':
u6.c:(.text+0x2647): undefined reference to `LJUSB_Write'
u6.c:(.text+0x2690): undefined reference to `LJUSB_Read'
CMakeFiles/serial.dir/src/u6.c.o: In function `ehFeedback':
u6.c:(.text+0x2940): undefined reference to `LJUSB_Write'
u6.c:(.text+0x2996): undefined reference to `LJUSB_Read'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/sam/catkin_ws/devel/lib/auto_grinder/serial] Error 1
make[1]: *** [auto_grinder/CMakeFiles/serial.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
[rosrun] Couldn't find executable named serial below /home/sam/catkin_ws/src/auto_grinder

Here is my CMakeList.txt file:

cmake_minimum_required(VERSION 2.8.3)
project(auto_grinder)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  rqt_gui
  rqt_gui_cpp
)

find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)

SET(CMAKE_CXX_FLAGS "-lusb-1.0")

catkin_package()

include_directories(${customLibary_INCLUDE_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS})

install(DIRECTORY include/${auto_grinder}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(DIRECTORY /usr/local/include/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

install(PROGRAMS scripts/auto_grinder
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

include_directories(/usr/local/lib)
include_directories(/usr/local/include)
add_library(mylabjack /usr/local/lib/liblabjackusb.so)
##add_library(libusb /usr/lib/x86_64-linux-gnu/libusb-1.0.so)
##add_executable(thislabjack /usr/include/liblabjackusb/labjackusb.c)
SET_TARGET_PROPERTIES(mylabjack PROPERTIES LINKER_LANGUAGE C)
#SET_TARGET_PROPERTIES(libusb PROPERTIES LINKER_LANGUAGE C)


add_executable(serial src/serial.cpp src/serialout.cpp src/motors.cpp src/keypad.cpp src/sensorinput.cpp src/u6.c)
target_link_libraries(serial ${catkin_LIBRARIES} mylabjack)
add_dependencies(serial auto_grinder_generate_messages_cpp)

catkin_python_setup()

I have been trying a lot of different things I have seen in other questions so it turned pretty messy. I know there is a similar question to this on the forums but they were using rosbuild rather than catkin so I was confused. I am using ubuntu ... (more)

edit retag flag offensive close merge delete

Comments

are you setting customLibary_INCLUDE_DIRS? I don't see that anywhere in the source...

allenh1 gravatar imageallenh1 ( 2014-07-11 11:10:03 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-16 14:06:28 -0600

samv03 gravatar image

I got it! Just had to add labjackusb to the target_link_libraries. Here is the cleaned up and working CMakeList.txt

cmake_minimum_required(VERSION 2.8.3)
project(auto_grinder)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  rqt_gui
  rqt_gui_cpp
)

find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)

catkin_package()

include_directories(${customLibary_INCLUDE_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS})

install(DIRECTORY include/${auto_grinder}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

install(PROGRAMS scripts/auto_grinder
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

include_directories(/usr/local/lib)
include_directories(/usr/local/include)


add_executable(serial src/serial.cpp src/serialout.cpp src/motors.cpp src/keypad.cpp src/u6.c src/sensorinput.cpp)
target_link_libraries(serial ${catkin_LIBRARIES} labjackusb)
add_dependencies(serial auto_grinder_generate_messages_cpp)

catkin_python_setup()
edit flag offensive delete link more

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: 2014-07-10 10:13:21 -0600

Seen: 259 times

Last updated: Jul 16 '14