ros / class_loader

ROS-independent library for dynamic class (i.e. plugin) introspection and loading from runtime libraries
http://www.ros.org/wiki/class_loader
35 stars 95 forks source link

linking tests fails with CMAKE_BUILD_TYPE=Debug #117

Closed dirk-thomas closed 5 years ago

dirk-thomas commented 5 years ago

Without specifying the build type Poco_LIBRARIES contains /usr/lib/libPocoFoundation.so;dl. When building debug the variable only contains dl - I assume because no debug libraries are available on the system.

As a result building the tests fails with unresolved symbols:

../devel/lib/libclass_loader.so: undefined reference to `typeinfo for Poco::RuntimeException'
../devel/lib/libclass_loader.so: undefined reference to `Poco::SharedLibrary::isLoaded() const'
../devel/lib/libclass_loader.so: undefined reference to `Poco::SharedLibrary::suffix[abi:cxx11]()'
../devel/lib/libclass_loader.so: undefined reference to `typeinfo for Poco::LibraryLoadException'
../devel/lib/libclass_loader.so: undefined reference to `typeinfo for Poco::LibraryAlreadyLoadedException'
../devel/lib/libclass_loader.so: undefined reference to `Poco::SharedLibrary::SharedLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
../devel/lib/libclass_loader.so: undefined reference to `typeinfo for Poco::NotFoundException'
../devel/lib/libclass_loader.so: undefined reference to `Poco::SharedLibrary::unload()'
nuclearsandwich commented 5 years ago

I'm not able to reproduce this. Can you please share more information about the workspace, environment, and build parameters.

dirk-thomas commented 5 years ago

I'm not able to reproduce this.

Can you describe how you have tried it?

Can you please share more information about the workspace, environment, and build parameters.

Just straight forward building the tests with build type Debug:

source /opt/ros/melodic
cd /tmp
git clone https://github.com/ros/class_loader.git
mkdir class_loader/build
cd class_loader/build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
make tests
nuclearsandwich commented 5 years ago

Can you describe how you have tried it?

I built it in a melodic workspace based on a prerelease container I had lying around with catkin_make_isolated.

catkin_make_isolated --cmake-args -DCMAKE_BUILD_TYPE=Debug -DCATKIN_ENABLE_TESTING=ON
nuclearsandwich commented 5 years ago

I see now. The issue title said building tests fails. But the tests build fine they just don't link correctly when run. Thanks for clarifying your workflow.

nuclearsandwich commented 5 years ago

The issue seems to be coming from cmake_modules.

The logic here handles debug libraries. I haven't traced where it's falling down yet.

I did create a little test package that exhibits successful results when finding poco without the cmake_modules package.

Consider

cmake_minimum_required(VERSION 3.5)
project(test_poco CXX)

find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Poco REQUIRED COMPONENTS Foundation)
message(STATUS "Poco_LIBRARIES ${Poco_LIBRARIES}")
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
-- Using CATKIN_DEVEL_PREFIX: /tmp/ws/src/class_loader/test_poco/build/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /tmp/ws/src/class_loader/test_poco/build/test_results
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.14
-- Searching for Poco library...
--   Found Poco!
-- components found: Foundationd.
-- Poco_LIBRARIES dl
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/ws/src/class_loader/test_poco/build

versus

cmake_minimum_required(VERSION 3.5)
project(test_poco CXX)

#find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Poco REQUIRED COMPONENTS Foundation)
message(STATUS "Poco_LIBRARIES ${Poco_LIBRARIES}")
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Poco_LIBRARIES Poco::Foundation
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/ws/src/class_loader/test_poco/build

Which raises the question of whether or not the FindPoco.cmake module is still desired if the cmake config in the upstream package is generally more successful.

nuclearsandwich commented 5 years ago

ros/cmake_modules#50 is open which is my proposed fix for Melodic.

dirk-thomas commented 5 years ago

ros/cmake_modules#50

Fixed with the latest release of cmake_modules.