From 481211073f0d7cc86648a52e4d7c615572c76ae6 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Thu, 20 Jul 2017 14:31:50 +0200 Subject: [PATCH] Build relocatable code. (#413) This is required to reuse code from cartographer_ros in cartographer_rviz. Otherwise linking fails with errors like these: ~~~ /usr/bin/ld: libcartographer_ros.a(msg_conversion.cc.o): relocation R_X86_64_32S against `_ZNSs4_Rep20_S_empty_rep_storageE' can not be use d when making a shared object; recompile with -fPIC ~~~ While this could be fixed locally in cartographer_ros, it is a reasonable default to compile with `-fPIC` always. --- cmake/functions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 5762f8e..3bfd343 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -72,7 +72,7 @@ macro(google_initialize_cartographer_project) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) endif() - set(GOOG_CXX_FLAGS "-pthread -std=c++11 ${GOOG_CXX_FLAGS}") + set(GOOG_CXX_FLAGS "-pthread -std=c++11 -fPIC ${GOOG_CXX_FLAGS}") google_add_flag(GOOG_CXX_FLAGS "-Wall") google_add_flag(GOOG_CXX_FLAGS "-Wpedantic")