From a8f694488d340a33e775481c083e7e76c1c9df6e Mon Sep 17 00:00:00 2001 From: jvallve <jvallve@iri.upc.edu> Date: Thu, 12 May 2022 18:02:40 +0200 Subject: [PATCH] strange linking bug fixed --- CMakeLists.txt | 31 ++++++++++++------------------- include/node.h | 1 - src/node.cpp | 5 ----- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd31cc..dfb4776 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.10) project(wolf_ros_node) -## Compile as C++11, supported in ROS Kinetic and newer -add_compile_options(-std=c++14) +## Compile as C++14 +add_compile_options(-std=c++14) +# -fPIC and -rdynamic ensure unique singleton instance across shared libraries (for factories) see: https://stackoverflow.com/a/8626922 +SET(CMAKE_CXX_FLAGS "-fPIC -rdynamic") find_package(catkin REQUIRED COMPONENTS roslib @@ -38,40 +40,31 @@ include_directories( ${catkin_INCLUDE_DIRS} ) - add_executable(${PROJECT_NAME} src/node.cpp) add_library(subscriber_${PROJECT_NAME} - src/subscriber_diffdrive.cpp - src/subscriber_odom2d.cpp) + src/subscriber_diffdrive.cpp + src/subscriber_odom2d.cpp) + add_library(publisher_${PROJECT_NAME} - src/publisher_graph.cpp - src/publisher_pose.cpp - src/publisher_trajectory.cpp - src/publisher_state_block.cpp - src/publisher_tf.cpp) + src/publisher_graph.cpp + src/publisher_pose.cpp + src/publisher_trajectory.cpp + src/publisher_state_block.cpp + src/publisher_tf.cpp) ## Specify libraries to link a library or executable target against target_link_libraries(subscriber_${PROJECT_NAME} ${catkin_LIBRARIES} - ceres wolfcore - yaml-cpp - dl ) target_link_libraries(publisher_${PROJECT_NAME} ${catkin_LIBRARIES} - ceres wolfcore - yaml-cpp - dl ) target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} - ceres wolfcore - yaml-cpp - dl ) \ No newline at end of file diff --git a/include/node.h b/include/node.h index 8ba4ef1..8324843 100644 --- a/include/node.h +++ b/include/node.h @@ -61,7 +61,6 @@ #include "publisher.h" using namespace wolf; -using namespace std; class WolfRosNode { diff --git a/src/node.cpp b/src/node.cpp index 8e43543..910cfda 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -84,12 +84,7 @@ WolfRosNode::WolfRosNode() WOLF_TRACE("Loading publisher " + type + " via " + lib_publisher); auto l = std::make_shared<LoaderRaw>(lib_publisher); - - FactoryPublisher::printCallbacks(); - FactoryPublisher::printAddress(); l->load(); - FactoryPublisher::printCallbacks(); - FactoryPublisher::printAddress(); //loaders_.push_back(l); WOLF_INFO("Pub: ", type, " name: ", name); -- GitLab