Build Peerconnection with WebRTC static library failed - c++

I met some issues when I wanted to build the peerconnection example with linking Webrtc as a static library.
My build environment and the target are both ubuntu 18.04, and I used the Github repo https://github.com/vsimon/webrtcbuilds to build the
Webrtc as a static library.
Then there were many link errors about absl libray, after some investigations, I added some build args to eliminate the majority of them as below:
is_debug=false
is_component_build=false
is_clang=false
rtc_include_tests=false
rtc_use_h264=true
rtc_enable_protobuf=false
use_rtti=true
use_custom_libcxx=false
treat_warnings_as_errors=false
use_ozone=true
But it still has several link errors that I can't tackle:
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::DeadlineFromTimeout(absl::Duration) [clone .isra.8]':
mutex.cc:(.text._ZN4abslL19DeadlineFromTimeoutENS_8DurationE.isra.8+0x24): undefined reference to `absl::TimeFromTimeval(timeval)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::AwaitWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex17AwaitWithDeadlineERKNS_9ConditionENS_4TimeE+0xa4): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::LockWhenWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex20LockWhenWithDeadlineERKNS_9ConditionENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::ReaderLockWhenWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex26ReaderLockWhenWithDeadlineERKNS_9ConditionENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::CondVar::WaitWithDeadline(absl::Mutex*, absl::Time)':
mutex.cc:(.text._ZN4absl7CondVar16WaitWithDeadlineEPNS_5MutexENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(bind.o): In function `absl::str_format_internal::FormatUntyped(absl::str_format_internal::FormatRawSinkImpl, absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)':
bind.cc:(.text._ZN4absl19str_format_internal13FormatUntypedENS0_17FormatRawSinkImplENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x159): undefined reference to `absl::str_format_internal::kTags'
bind.cc:(.text._ZN4absl19str_format_internal13FormatUntypedENS0_17FormatRawSinkImplENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x457): undefined reference to `absl::str_format_internal::ConsumeUnboundConversion(char const*, char const*, absl::str_format_internal::UnboundConversion*, int*)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(bind.o): In function `absl::str_format_internal::Summarize[abi:cxx11](absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)':
bind.cc:(.text._ZN4absl19str_format_internal9SummarizeB5cxx11ENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x18b): undefined reference to `absl::str_format_internal::kTags'
bind.cc:(.text._ZN4absl19str_format_internal9SummarizeB5cxx11ENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0xa12): undefined reference to `absl::str_format_internal::ConsumeUnboundConversion(char const*, char const*, absl::str_format_internal::UnboundConversion*, int*)'
I hope anyone can give me some hints to fix them, thanks very much!

Related

Facing undefined reference error after upgrading Protobuf

I had upgraded the protoc version from 3.0.0 to 3.15.2 . Now I am unable to compile the program that uses protoc output files(*.pb.cpp , *.pb.h). I am getting the error as shown below:
In function `google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:694: undefined reference to `google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)'
In function `google::protobuf::internal::TaggedPtr<std::string>::Set(std::string*)':
/usr/local/include/google/protobuf/arenastring.h:101: undefined reference to `google::protobuf::internal::fixed_address_empty_string'
In function `google::protobuf::Arena::AllocateAlignedWithHook(unsigned long, unsigned long, std::type_info const*)':
/usr/local/include/google/protobuf/arena.h:700: undefined reference to `google::protobuf::Arena::AllocateAlignedWithHook(unsigned long, std::type_info const*)'
In function `google::protobuf::internal::ReadTag(char const*, unsigned int*, unsigned int)':
/usr/local/include/google/protobuf/parse_context.h:544: undefined reference to `google::protobuf::internal::ReadTagFallback(char const*, unsigned int)'
In function `google::protobuf::Arena::SpaceAllocated() const':
/usr/local/include/google/protobuf/arena.h:349: undefined reference to `google::protobuf::internal::ThreadSafeArena::SpaceAllocated() const'
In function `google::protobuf::UnknownFieldSet::Clear()':
/usr/local/include/google/protobuf/unknown_field_set.h:312: undefined reference to `google::protobuf::UnknownFieldSet::ClearFallback()'
I am facing this undefined reference error in google::protobuf path . There are so many lines of same errors of the kind show above.
Do I have to include any other additional library for the upgraded version ?
or
Do I have to change path of any library ? as here undefined reference to google protobuf
Any kind of help with respect to this is appreciated .
Thank you

Can't link std::filesystem even with -lstdc++fs

I'm trying to compile an application that uses std::filesystem. I'm using CMake for the build system, and g++-8 as a compiler.
My CMakeLists.txt includes target_link_libraries(<target_name> PUBLIC stdc++fs) and set(CMAKE_CXX_STANDARD 17)
make VERBOSE=1 shows that -lstdc++fs is used in the linker command.
Despite this, I get undefined references to std::filesystem components everywhere they are used.
It compiles fine in Docker, so it's clearly an environment issue.
Any tips for tracking this down?
EDIT:
I can't post the exact error message because of company rules, and it's also super long. I'll post a truncated, anonymized version though:
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `ProjectName::ClassName::update(ProjectName::Body&)':
/home/username/prog/bots/src/ui/dir_a/file_a.cpp:30: undefined reference to `std::filesystem::current_path[abi:cxx11]()'
/home/username/prog/bots/src/ui/dir_a/file_a.cpp:35: undefined reference to `std::filesystem::create_directories(std::filesystem::__cxx11::path const&)'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::__cxx11::path::operator+=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/8/bits/fs_path.h:817: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::__cxx11::path::operator+=(char const*)':
/usr/include/c++/8/bits/fs_path.h:825: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::exists(std::filesystem::__cxx11::path const&)':
/usr/include/c++/8/bits/fs_ops.h:121: undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
CMakeFiles/ProjectName.dir/src/ui/dir_b/file_b.cpp.o: In function `ProjectName::ClassName::update[abi:cxx11]()':
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:30: undefined reference to `std::filesystem::current_path[abi:cxx11]()'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:34: undefined reference to `std::filesystem::create_directories(std::filesystem::__cxx11::path const&)'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:36: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:40: undefined reference to `std::filesystem::__cxx11::path::replace_extension(std::filesystem::__cxx11::path const&)'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:36: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
CMakeFiles/ProjectName.dir/src/ui/dir_b/file_b.cpp.o: In function `std::filesystem::__cxx11::path::path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::filesystem::__cxx11::path::format)':
/usr/include/c++/8/bits/fs_path.h:177: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
It continues like that for a hundred or so lines.
Software versions:
Ubuntu 18.04
g++-8 (installed with `apt`)
CMake 3.14.2
Upgrading to g++ 9 fixed the problem, but if anyone knows how to fix the problem and still use g++ 8 I'll accept that answer.

Linker errors building libcxx on fresh Ubuntu install

I followed the clang/llvm directions TO THE TEE (and this is my 5th time doing it so I'm very certain I put everything in the right place). The directions I followed are here: https://clang.llvm.org/get_started.html
(steps 1-7, including the optional ones).
At that point everything is fine, no error messages.
When I try to build with 'make', when it gets to libcxx it has linker errors:
.
.
.
[100%] Built target cxx_objects
[100%] Linking CXX shared library ../../../lib/libc++.so
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::(anonymous namespace)::__throw_runtime_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0xf): undefined reference to `__cxa_allocate_exception'
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0x33): undefined reference to `__cxa_throw'
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0x3e): undefined reference to `__cxa_free_exception'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::ctype_byname<wchar_t>::do_widen(char) const':
locale.cpp:(.text._ZNKSt3__112ctype_bynameIwE8do_widenEc+0x43): undefined reference to `__cxa_call_unexpected'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::ctype_byname<wchar_t>::do_widen(char const*, char const*, wchar_t*) const':
locale.cpp:(.text._ZNKSt3__112ctype_bynameIwE8do_widenEPKcS3_Pw+0x7a): undefined reference to `__cxa_call_unexpected'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::ctype_byname<wchar_t>::do_narrow(wchar_t, char) const':
locale.cpp:(.text._ZNKSt3__112ctype_bynameIwE9do_narrowEwc+0x46): undefined reference to `__cxa_call_unexpected'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::ctype_byname<wchar_t>::do_narrow(wchar_t const*, wchar_t const*, char, char*) const':
locale.cpp:(.text._ZNKSt3__112ctype_bynameIwE9do_narrowEPKwS3_cPc+0x8d): undefined reference to `__cxa_call_unexpected'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::locale::__imp::use_facet(long) const [clone .part.18]':
locale.cpp:(.text.unlikely._ZNKSt3__16locale5__imp9use_facetEl.part.18+0x7): undefined reference to `__cxa_allocate_exception'
locale.cpp:(.text.unlikely._ZNKSt3__16locale5__imp9use_facetEl.part.18+0x28): undefined reference to `__cxa_throw'
CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In function `std::__1::__time_get_c_storage<char>::__weeks() const':
locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE7__weeksEv+0x21): undefined reference to `__cxa_guard_acquire'
locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE7__weeksEv+0x167): undefined reference to `__cxa_guard_release'
locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE7__weeksEv+0x178): undefined reference to `__cxa_guard_acquire'
locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE7__weeksEv+0x35a): undefined reference to `__cxa_guard_release'
locale.cpp:(.text._ZNKSt3__120__time_get_c_storageIcE7__weeksEv+0x383): undefined reference to `__cxa_guard_abort'
.
.
.
What am I doing wrong? Again, a fresh Ubuntu install, so I didn't install anything with apt install or change my PATH or anything like that.

Boost C++ code not building, can someone help me with library linking?

I've followed the tutorial from here to set up my Eclipse installation with Boost and the examples at the bottom of the tutorial to test the compilation work. I'm trying to use asio for sockets, but I'm receiving the following when compiling:
**** Build of configuration Debug for project Client ****
**** Internal Builder is used for build ****
g++ -IC:\MinGW\Boost\include\boost-1_53 -O0 -g3 -Wall -c -fmessage-length=0 -o src\Client.o ..\src\Client.cpp
g++ -LC:\MinGW\Boost\lib -o Client.exe src\Client.o
src\Client.o: In function `__static_initialization_and_destruction_0':
C:/MinGW/Boost/include/boost-1_53/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
C:/MinGW/Boost/include/boost-1_53/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
C:/MinGW/Boost/include/boost-1_53/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
src\Client.o: In function `boost::system::error_code::error_code()':
C:/MinGW/Boost/include/boost-1_53/boost/system/error_code.hpp:315: undefined reference to `boost::system::system_category()'
src\Client.o: In function `boost::asio::error::get_system_category()':
C:/MinGW/Boost/include/boost-1_53/boost/asio/error.hpp:216: undefined reference to `boost::system::system_category()'
src\Client.o: In function `boost::asio::detail::winsock_init_base::startup(boost::asio::detail::winsock_init_base::data&, unsigned char, unsigned char)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/winsock_init.ipp:39: undefined reference to `__imp_WSAStartup'
src\Client.o: In function `boost::asio::detail::winsock_init_base::cleanup(boost::asio::detail::winsock_init_base::data&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/winsock_init.ipp:48: undefined reference to `__imp_WSACleanup'
src\Client.o: In function `boost::asio::detail::socket_ops::clear_last_error()':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:51: undefined reference to `__imp_WSASetLastError'
src\Client.o: In function `boost::asio::detail::socket_ops::close(unsigned long long, unsigned char&, bool, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:297: undefined reference to `__imp_closesocket'
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:314: undefined reference to `__imp_ioctlsocket'
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:329: undefined reference to `__imp_closesocket'
src\Client.o: In function `boost::asio::detail::socket_ops::recv(unsigned long long, _WSABUF*, unsigned long long, int, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:683: undefined reference to `__imp_WSARecv'
src\Client.o: In function `boost::asio::detail::socket_ops::send(unsigned long long, _WSABUF const*, unsigned long long, int, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1066: undefined reference to `__imp_WSASend'
src\Client.o: In function `boost::asio::detail::socket_ops::socket(int, int, int, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1294: undefined reference to `__imp_WSASocketA'
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1305: undefined reference to `__imp_setsockopt'
src\Client.o: In function `boost::asio::detail::socket_ops::poll_read(unsigned long long, unsigned char, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1716: undefined reference to `__imp_select'
src\Client.o: In function `boost::asio::detail::socket_ops::poll_connect(unsigned long long, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1797: undefined reference to `__imp_select'
src\Client.o: In function `boost::asio::detail::socket_ops::translate_addrinfo_error(int)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:2869: undefined reference to `__imp_WSAGetLastError'
src\Client.o: In function `boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&, addrinfo**, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:2887: undefined reference to `__imp_getaddrinfo'
src\Client.o: In function `boost::asio::detail::socket_ops::freeaddrinfo(addrinfo*)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:2930: undefined reference to `__imp_freeaddrinfo'
src\Client.o: In function `unsigned long long boost::asio::detail::socket_ops::error_wrapper<unsigned long long>(unsigned long long, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:62: undefined reference to `__imp_WSAGetLastError'
src\Client.o: In function `int boost::asio::detail::socket_ops::error_wrapper<int>(int, boost::system::error_code&)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:62: undefined reference to `__imp_WSAGetLastError'
src\Client.o: In function `int boost::asio::detail::socket_ops::call_connect<int>(int boost::asio::detail::socket_ops::msghdr::*, unsigned long long, sockaddr const*, unsigned long long)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:452: undefined reference to `__imp_connect'
src\Client.o: In function `int boost::asio::detail::socket_ops::call_setsockopt<int>(int boost::asio::detail::socket_ops::msghdr::*, unsigned long long, int, int, void const*, unsigned long long)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1340: undefined reference to `__imp_setsockopt'
src\Client.o: In function `int boost::asio::detail::socket_ops::call_getsockopt<int>(int boost::asio::detail::socket_ops::msghdr::*, unsigned long long, int, int, void*, unsigned long long*)':
C:/MinGW/Boost/include/boost-1_53/boost/asio/detail/impl/socket_ops.ipp:1426: undefined reference to `__imp_getsockopt'
collect2.exe: error: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 4033 ms.
I'm assuming I've gone wrong somewhere when linking the libraries. Could somebody please explain what the author of that tutorial meant by
Under libraries, add the specific boost libraries you need.
For example I have added:
boost_thread-mgw47-mt-d-1_52
boost_system-mgw47-mt-d-1_52
and explain (in detail) how to go about this in Eclipse please (for both Debug and Release)? Thanks.
Oh and if you want the code, it's simply the code found here.
The errors you get are indeed linking errors, because of missing libraries (probably the ones you list).
A quick search led to these two SO entries:
How to add a library to eclipse c project
C++: external library in CDT
Note that in certain versions of eclipse/CDT there's a Library tab in the symbols & path configuration window, but it doesn't seem to be present in all versions, so you must resort to the linker configuration panel as explained in the answers linked above.
If you went through the previous tutorial from the same site you link in your question (the one about setting up eclipse and cdt), and managed to get the sample programme compiled, then the 2 boost libraries are the only missing. Otherwise, you might need to add a few others (some of the missing symbols in the error messages pertain to the winsock system library).

ROS Linking errors using boost::filesystem library using C++ under linux

I get the following errors:
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `directory_iterator':
/usr/include/boost/filesystem/v3/operations.hpp:594: undefined reference to `boost::filesystem3::detail::directory_iterator_construct(boost::filesystem3::directory_iterator&, boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `path<boost::filesystem3::directory_entry>':
/usr/include/boost/filesystem/v3/path.hpp:134: undefined reference to `boost::filesystem3::path_traits::dispatch(boost::filesystem3::directory_entry const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::codecvt<wchar_t, char, __mbstate_t> const&)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `is_directory':
/usr/include/boost/filesystem/v3/operations.hpp:223: undefined reference to `boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::iterator_facade<boost::filesystem3::directory_iterator, boost::filesystem3::directory_entry, boost::single_pass_traversal_tag, boost::filesystem3::directory_entry&, int>::operator++()':
/usr/include/boost/filesystem/v3/operations.hpp:630: undefined reference to `boost::filesystem3::detail::directory_iterator_increment(boost::filesystem3::directory_iterator&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `is_directory':
/usr/include/boost/filesystem/v3/operations.hpp:223: undefined reference to `boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `~dir_itr_imp':
/usr/include/boost/filesystem/v3/operations.hpp:563: undefined reference to `boost::filesystem3::detail::dir_itr_close(void*&, void*&)'
/usr/include/boost/filesystem/v3/operations.hpp:563: undefined reference to `boost::filesystem3::detail::dir_itr_close(void*&, void*&)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
I've seen quite a few posts with similar errors. In pretty much all of those posts (e.g. Linking Boost Library in Linux) it seems the solution is, that you need to add the -lboost_filesystem and -lboost_system flags. I've tried adding these as lflags or cflags to the manifest.xml, but that changes absolutely nothing. And I've tried adding something to the CMakeLists.txt of my package, but I guess I was doing that wrong.
So any ideas?
You'll need to add lines like the following to your CMakeLists.txt:
rosbuild_add_boost_directories()
rosbuild_link_boost(ndt_visualizer filesystem system)
See http://www.ros.org/wiki/rosbuild/CMakeLists#rosbuild_link_boost for some more details.
Adding lines to the lflags or cflags in you manifest affects other packages linking against yours, not yours linking against others.
In the future, ROS questions are better asked on ROS Answers per the Support Guidelines
Just as a small follow-up, I was having a problem with undefined references to something involving file statuses and error codes.
The problem came up with the ordering library linking ("less dependent" libraries come after "more dependent" libraries, at least with GCC). My project used a custom library whcih was dependent on Boost.Filesystem and yaml-cpp. Before, I had my custom library linked after the boost libraries, bu that did not work. I had to fix it by making sure that boost was linked afterwards:
rosbuild_add_boost_directories()
rosbuild_add_executable(${PROJECT_NAME} ${SRCS})
target_link_libraries(${PROJECT_NAME} custom_lib yaml-cpp)
rosbuild_link_boost(${PROJECT_NAME} filesystem system)