Dear All,
I am using Ubuntu 14.04 and ROS Indigo.
I have created a pkg named "joy" in which there are two source file named `joystick.cpp` and `js_info.cpp` under `joy/src` folder. also i have header file `joystick.h` under `include/joy` folder.
i have compiled that 3 files and they work correctly.
But when i placed this files as told you above, gives me error as shown below:
CMake Error at joy/CMakeLists.txt:61 (target_link_libraries):
Target "joystick" of type EXECUTABLE may not be linked into another target.
One may link only to STATIC or SHARED libraries, or to executables with the
ENABLE_EXPORTS property set.
-- Configuring incomplete, errors occurred!
See also "/home/darshan/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/darshan/catkin_ws/build/CMakeFiles/CMakeError.log".
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
This below shown is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.3)
project(joy)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS roscpp rospy std_msgs
)
include_directories(include
${catkin_INCLUDE_DIRS}
)
add_executable(joystick src/joystick.cpp)
target_link_libraries(joystick ${catkin_LIBRARIES})
add_executable(js_info src/js_info.cpp)
target_link_libraries(js_info ${catkin_LIBRARIES} joystick)
Please provide me the solution. I would be thankful to all of you.
---
Edit: Thank you so much for quick and prompt reply.
But if i change that line to
target_link_libraries(js_info ${catkin_LIBRARIES} )
like this. I get the following error.
darshan@darshan-Inspiron-N4010:~/catkin_ws$ catkin_make
Base path: /home/darshan/catkin_ws
Source space: /home/darshan/catkin_ws/src
Build space: /home/darshan/catkin_ws/build
Devel space: /home/darshan/catkin_ws/devel
Install space: /home/darshan/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/darshan/catkin_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/darshan/catkin_ws/build"
####
[ 0%] Built target _rosserial_arduino_generate_messages_check_deps_Test
[ 0%] [ 0%] [ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestParam
Built target _rosserial_msgs_generate_messages_check_deps_RequestServiceInfo
Built target _rosserial_arduino_generate_messages_check_deps_Adc
[ 0%] Built target _rosserial_msgs_generate_messages_check_deps_Log
[ 0%] Built target _rosserial_msgs_generate_messages_check_deps_TopicInfo
[ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestMessageInfo
[ 0%] Built target std_msgs_generate_messages_py
[ 13%] Built target abc
[ 13%] Built target _beginner_tutorials_generate_messages_check_deps_Num
[ 13%] Built target std_msgs_generate_messages_lisp
[ 13%] Built target _beginner_tutorials_generate_messages_check_deps_AddTwoInts
[ 13%] Built target std_msgs_generate_messages_cpp
[ 15%] Built target hello
Linking CXX executable /home/darshan/catkin_ws/devel/lib/joy/joystick
[ 28%] Built target gui_ros
Linking CXX executable /home/darshan/catkin_ws/devel/lib/joy/js_info
[ 30%] Built target hello_world
[ 43%] Built target example
[ 46%] Built target rosserial_arduino_generate_messages_lisp
[ 47%] Built target turtle_teleop_joy
[ 53%] Built target rosserial_arduino_generate_messages_py
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/darshan/catkin_ws/devel/lib/joy/joystick] Error 1
make[1]: *** [joy/CMakeFiles/joystick.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 56%] Built target rosserial_arduino_generate_messages_cpp
[ 63%] Built target rosserial_msgs_generate_messages_cpp
CMakeFiles/js_info.dir/src/js_info.cpp.o: In function `main':
js_info.cpp:(.text+0x7a): undefined reference to `Joystick::Joystick(char const*)'
js_info.cpp:(.text+0x204): undefined reference to `Joystick::getName()'
js_info.cpp:(.text+0x234): undefined reference to `Joystick::numAxes()'
js_info.cpp:(.text+0x274): undefined reference to `Joystick::numButtons()'
js_info.cpp:(.text+0x301): undefined reference to `Joystick::getAxis(int)'
js_info.cpp:(.text+0x339): undefined reference to `Joystick::getAxis(int)'
js_info.cpp:(.text+0x3c9): undefined reference to `Joystick::getButton(int)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/darshan/catkin_ws/devel/lib/joy/js_info] Error 1
make[1]: *** [joy/CMakeFiles/js_info.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
darshan@darshan-Inspiron-N4010:~/catkin_ws$.
↧