ros2 / rcl_logging

Logging implementations for ROS 2.
Apache License 2.0
18 stars 34 forks source link

rcl_logging_spdlog breaks the build under libc++ #34

Open rotu opened 4 years ago

rotu commented 4 years ago

Similar to #14, compilation fails in the linking phase when building with the Clang option -stdlib=libc++.

Ubuntu Focal / Clang 11

Starting >>> rcl
--- stderr: rcl                                       
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)
ld.lld: error: ld.lld: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
ld.lld: error: ld.lld: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&)
error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&)ld.lld
: ld.llderror: : /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)error: 
/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
ld.lldld.lld: : error: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

ld.lldld.lld: : error: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

ld.lldld.lld: : error: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)

ld.lld: ld.llderror: : /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)error: 
/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)ld.lld
: ld.llderror: : /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)error: 
/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)ld.lld
: ld.lld: error: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()
/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()ld.lld
: ld.llderror: : /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)error: 
/opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
clangld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&): 
error: linker command failed with exit code 1 (use -v to see invocation)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)
make[2]: *** [test/CMakeFiles/client_fixture__rmw_fastrtps_dynamic_cpp.dir/build.make:150: test/client_fixture__rmw_fastrtps_dynamic_cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:362: test/CMakeFiles/client_fixture__rmw_fastrtps_dynamic_cpp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/CMakeFiles/test_security.dir/build.make:114: test/test_security] Error 1
make[1]: *** [CMakeFiles/Makefile2:306: test/CMakeFiles/test_security.dir/all] Error 2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/CMakeFiles/test_validate_topic_name.dir/build.make:111: test/test_validate_topic_name] Error 1
make[1]: *** [CMakeFiles/Makefile2:335: test/CMakeFiles/test_validate_topic_name.dir/all] Error 2
make[2]: *** [test/CMakeFiles/service_fixture__rmw_fastrtps_dynamic_cpp.dir/build.make:150: test/service_fixture__rmw_fastrtps_dynamic_cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:389: test/CMakeFiles/service_fixture__rmw_fastrtps_dynamic_cpp.dir/all] Error 2
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/CMakeFiles/test_timer__rmw_fastrtps_dynamic_cpp.dir/build.make:114: test/test_timer__rmw_fastrtps_dynamic_cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:447: test/CMakeFiles/test_timer__rmw_fastrtps_dynamic_cpp.dir/all] Error 2
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::flush_()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::sink_it_(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::basic_file_sink<std::__1::mutex>::basic_file_sink(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter> >)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::sinks::base_sink<std::__1::mutex>::flush()
ld.lld: error: /opt/ros/master/install/lib/librcl_logging_spdlog.so: undefined reference to spdlog::logger::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, spdlog::pattern_time_type)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/CMakeFiles/test_namespace__rmw_fastrtps_dynamic_cpp.dir/build.make:152: test/test_namespace__rmw_fastrtps_dynamic_cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:418: test/CMakeFiles/test_namespace__rmw_fastrtps_dynamic_cpp.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< rcl    [ Exited with code 2 ]
rotu commented 4 years ago

The build does succeed if I rebuild spdlog_vendor with: colcon build --packages-select spdlog_vendor --cmake-args -DFORCE_BUILD_VENDOR_PKG=1

so maybe this issue should be moved to the spdlog_vendor repo.

rotu commented 4 years ago

I'm also a little concerned that the linker error happens when linking the project rcl instead of the project rcl_logging

hidmic commented 4 years ago

Same as with https://github.com/ros2/rcl_logging/issues/14, contributions to address this issue are more than welcomed e.g. updating spdlog_vendor cmake code to force source builds in this case.