0
$\begingroup$

Gazebo Answers logo

I've been stuck on this issue for an embarrassingly long period of time, and would be very grateful for any help. I'm very new to c++ and CMake, so it's likely I'm overlooking something quite obvious.

When I run Gazebo with a plugin I wrote, plank_drop.cc, I get the following error:

gzserver: symbol lookup error: /home/plugins/build/libPlankDrop.so: undefined symbol: _Z4joinIdENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS0_4listIT_SaIS7_EEES5_

The symbol's name leads me to believe the issue is in the join function, called within plank_drop.cc, and defined in the extra_functions.cc.

I've added join() to the scope of plank_drop.cc like so:

#include "extra_functions.h"

And the compiler doesn't complain. It never seems to compain at compile time, or link time. It only fails at runtime. I've set this up in my CMakeList.txt like this:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

add_library(PlankDrop SHARED plank_drop.cc)
add_library(CamRecord SHARED cam_record.cc)
add_library(ExtraFunctions SHARED extra_functions.cc extra_functions.h)

target_link_libraries(PlankDrop CamRecord ExtraFunctions ${GAZEBO_LIBRARIES})

The relevant parts of my source code is here. All of my solutions just introduce new issues that are equally confusing.


Originally posted by david_d on Gazebo Answers with karma: 5 on 2018-12-13

Post score: 0


Original comments

Comment by david_d on 2018-12-13:
So, following this page: http://gdwarner.blogspot.com/2009/03/c-runtime-symbol-lookup-error.html

Using nm libPlankDrop.so | c++filt, this symbol is the problem:

U std::__cxx11::basic_string<char, std::char_traits, std::allocator > join(std::__cxx11::list<double, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)

I am still very confused.

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

In C++, you usually have to define template functions inside the header file. Here is a better explanation.

Also, you might need to add GAZEBO_VISIBLE macro to your functions if you want them to be available elsewhere. This won't apply to your template classes/function though. You'll need to include gazebo/util/system.hh to get the macro.


Originally posted by azeey with karma: 704 on 2018-12-14

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by david_d on 2018-12-14:
Thank you for your help. I'd also like to thank Jordan Liviero, who made a merge request on gitlab with this solution. Unfortunately, I didn't see either until I had already figured out a workaround myself.

https://gitlab.com/daviddaish/pose-pipeline/merge_requests/1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.