cmakelists compiling questions
Hi, this is a new linux user. When I compile my CMakelists, it gives me this error.
/usr/bin/ld: //usr/local/lib/libjsoncpp.a(json_reader.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPI
C
//usr/local/lib/libjsoncpp.a: error adding symbols: Bad value
I want to add my own global planner into the ros navigation stack. So I replace everything in carrort planner with "test_planner", and nothing changed otherwise. Now I want to change the content of Make_plan function to make my own plan. I read the pose from a .json file, so I have to use libjsoncpp. So I go to CMakelists.txt, and change the code below:
add_library(test_planner src/test_planner.cpp)
target_link_libraries(test_planner
${catkin_LIBRARIES}
)
to:
add_library(test_planner src/test_planner.cpp)
target_link_libraries(test_planner
${catkin_LIBRARIES}
jsoncpp
)
jsoncpp can be used to call libjsoncpp in my directory:/usr/local/lib.libjosncpp.a, this kind of change can be used for my other file compiling but not for this pluggin. It gives this errormessage:
/usr/bin/ld: //usr/local/lib/libjsoncpp.a(json_reader.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPI
C
//usr/local/lib/libjsoncpp.a: error adding symbols: Bad value
I have no idea how to fix this error in Cmakelists.txt.
Here is my CMakelists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(test_planner)
find_package(catkin REQUIRED
COMPONENTS
roscpp
tf
nav_core
costmap_2d
base_local_planner
pluginlib
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_definitions(${EIGEN_DEFINITIONS})
catkin_package(
INCLUDE_DIRS include
LIBRARIES test_planner
CATKIN_DEPENDS
roscpp
pluginlib
costmap_2d
base_local_planner
nav_core
)
add_library(test_planner src/test_planner.cpp)
target_link_libraries(test_planner
${catkin_LIBRARIES}
jsoncpp
)
install(TARGETS test_planner
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
PATTERN ".svn" EXCLUDE
)
install(FILES bgp_plugin.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)