I just wrote a little program using the boost filesystem library. Now it comes with some weird linking errors.
I already tried reordering the libraries, checked compiler version used for the boost binaries (Boost 1.51.0; MinGW 4.7.1 static libraries) and my MinGW version - 4.7.1.
Has someone an idea what else the cause for this could be?
Thanks in advance.
The output of the linker was:
obj\Debug\main.o: In function `ZN5boost10filesystem6existsERKNS0_4pathE':
C:/boost_1_51_0/boost/filesystem/operations.hpp:289: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
obj\Debug\main.o: In function `ZN5boost10filesystem4pathC1IA15_cEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE':
C:/boost_1_51_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
obj\Debug\main.o: In function `ZN5boost10filesystem11path_traits8dispatchISbIwSt11char_traitsIwESaIwEEEEvRKSsRT_RKSt7codecvtIwciE':
C:/boost_1_51_0/boost/filesystem/path_traits.hpp:174: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string, std::allocator >&, std::codecvt const&)'
I linked to the following libraries (set in Code::Blocks build options):
...\boost_1_51_0\stage\lib\libboost_system-mgw47-mt-d-1_51.a
...\boost_1_51_0\stage\lib\libboost_filesystem-mgw47-mt-d-1_51.a
The source Code (the interesting parts, i.e. the parts using boost):
//...
#define BOOST_SYSTEM_NO_DEPRECATED
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
//...
int main()
{
boost::filesystem::path p("./file.txt");
if(boost::filesystem::exists(p)) cout
//...
}
//...
Related
I am working with the TensorFlow repository and have used it to build both a static and dynamic library from c++ code using Bazel.
I am trying to use the static library (.a) with a c script (main.c). At compile time I get a huge amount of 'undefined reference' errors.
However, if I used the dynamic version (.so) of the library it successfully compiles and runs.
I have tested the libraries with a c++ script (main.cpp), this works for both.
I have seen online that it could be something to do with using extern "C" but it seems odd that it would work for the dynamic library and not the static?
Further Information
Lets say the library is libconv2d
I am building the dynamic library with:
cc_binary(
name = "conv2d",
deps = [
":runtime_conv2d",
],
linkshared = True,
visibility = ["//visibility:public"],
)
where runtime_conv2d is built here and the function I am using from the library is:
header file
source file
For the static library I am using this to build the library using Bazel.
When compiling (using clang-12 for requirement purposes):
clang-12 main.c module.ll libconv2d.a
where main.c calls a function in the LLVM module.ll which in turn calls the function in the library.
This throws a huge error, a small section of which can be seen below:
libllvm_static_test1.a(jit_gates_reduction.pic.o):(.data.rel.ro._ZTIN4dnnl4impl3cpu3x6421jit_gates_reduction_tE[_ZTIN4dnnl4impl3cpu3x6421jit_gates_reduction_tE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
libllvm_static_test1.a(cache_blob_id.pic.o): In function `dnnl::impl::cache_blob_id_t::get(dnnl_engine const*, dnnl::impl::primitive_desc_t const*)':
cache_blob_id.cpp:(.text._ZN4dnnl4impl15cache_blob_id_t3getEPK11dnnl_enginePKNS0_16primitive_desc_tE+0x9a): undefined reference to `std::__once_callable'
cache_blob_id.cpp:(.text._ZN4dnnl4impl15cache_blob_id_t3getEPK11dnnl_enginePKNS0_16primitive_desc_tE+0xb1): undefined reference to `std::__once_call'
cache_blob_id.cpp:(.text._ZN4dnnl4impl15cache_blob_id_t3getEPK11dnnl_enginePKNS0_16primitive_desc_tE+0xd8): undefined reference to `__once_proxy'
cache_blob_id.cpp:(.text._ZN4dnnl4impl15cache_blob_id_t3getEPK11dnnl_enginePKNS0_16primitive_desc_tE+0xec): undefined reference to `std::__throw_system_error(int)'
libllvm_static_test1.a(cache_blob_id.pic.o): In function `void std::vector<unsigned char, std::allocator<unsigned char> >::_M_range_insert<unsigned char const*>(__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char const*, unsigned char const*, std::forward_iterator_tag)':
cache_blob_id.cpp:(.text._ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag[_ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag]+0xf5): undefined reference to `operator delete(void*)'
cache_blob_id.cpp:(.text._ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag[_ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag]+0x1d7): undefined reference to `operator new(unsigned long)'
cache_blob_id.cpp:(.text._ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag[_ZNSt6vectorIhSaIhEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS1_EET_S9_St20forward_iterator_tag]+0x28f): undefined reference to `std::__throw_length_error(char const*)'
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!
I have tried to include Boost in Qt Creator since yesterday. But it doesn't work.
INCLUDEPATH += C:\boost_1_59_0
But how do I that with the ".a" files?
Sorry for my bad english.
Error Message:
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o): duplicate section `.data$_ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name[__ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name]' has different size
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size
debug/main.o: In function `ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE4failENS_15regex_constants10error_typeEiSsi':
C:/boost_1_59_0/boost/regex/v4/basic_regex_parser.hpp:220: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o: In function `ZN5boost9re_detail19basic_regex_creatorIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE16fixup_recursionsEPNS0_14re_syntax_baseE':
C:/boost_1_59_0/boost/regex/v4/basic_regex_creator.hpp:774: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
C:/boost_1_59_0/boost/regex/v4/basic_regex_creator.hpp:856: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o: In function `ZN5boost9re_detail19basic_regex_creatorIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE16create_startmapsEPNS0_14re_syntax_baseE':
C:/boost_1_59_0/boost/regex/v4/basic_regex_creator.hpp:922: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o: In function `ZN5boost9re_detail19basic_regex_creatorIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE15create_startmapEPNS0_14re_syntax_baseEPhPjh':
C:/boost_1_59_0/boost/regex/v4/basic_regex_creator.hpp:1125: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
debug/main.o: In function `ZNK5boost9re_detail31cpp_regex_traits_implementationIcE18lookup_collatenameEPKcS4_':
C:/boost_1_59_0/boost/regex/v4/cpp_regex_traits.hpp:679: undefined reference to `boost::re_detail::lookup_default_collate_name(std::string const&)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x30): undefined reference to `__gxx_personality_sj0'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x6c): undefined reference to `_Unwind_SjLj_Register'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x261): undefined reference to `_Unwind_SjLj_Unregister'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x430): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x4ec): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x5dc): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x74e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned int)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x76d): undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x84c): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x8ae): undefined reference to `_Unwind_SjLj_Resume'
C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o):cpp_regex_traits.cpp:(.text+0x937): undefined reference to `_Unwind_SjLj_Resume'
C:/Qt/Qt5.5.0/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/boost_1_59_0/stage/lib/libboost_regex-mgw51-mt-1_59.a(cpp_regex_traits.o): bad reloc address 0x50 in section `.rdata'
collect2.exe: error: ld returned 1 exit status
To link external libraries in Qt project you should provide required linker options. Those options can be added to LIBS variable in the .pro file.
According to Link Your Program to a Boost Library:
Auto-Linking
Most Windows compilers and linkers have so-called “auto-linking
support,” which eliminates the second challenge. Special code in Boost
header files detects your compiler options and uses that information
to encode the name of the correct library into your object files; the
linker selects the library with that name from the directories you've
told it to search.
The GCC toolchains (Cygwin and MinGW) are notable exceptions; GCC
users should refer to the linking instructions for Unix variant OSes
for the appropriate command-line options to use.
For MinGW the library search path is added by -Lpath option and the library name that should be linked by -llibrary, where library is the library name dropping the filename's leading lib and trailing suffix (.a in this case):
LIBS += -L"C:/boost_library_directory" -lname1 -lname2
Update according to new log of error messages
You use two different MinGW compilers:
MinGW 4.9.2 shipped with Qt
external MinGW 5.1.0 to build Boost
There is too large gap between those compilers and your Boost binaries are not compatible with Qt compiler.
I was able to reproduce your error messages using MinGW 5.1.0 for Boost and MinGW 4.8 in my Qt installation.
Build Boost using compiler provided by Qt. Set proper toolchain path for building Boost:
PATH=C:\Qt\Qt5.5.0\Tools\mingw492_32\bin;%PATH%
It should work with proper library versions, for example -lboost_regex-mgw492-mt-1_59.
Note that there are also two types of Boost binaries: release and debug (tagged by -d in file name). According to doc:
Although it's true that sometimes these choices don't affect binary
compatibility with other compiled code, you can't count on that with
Boost libraries.
So, you may want different project options for debug and release builds. In Qt .pro it can be done by testing CONFIG variable:
# set common library path
LIBS += -L"C:/boost_1_59_0/stage/lib"
CONFIG(debug, debug|release) {
# debug libraries
LIBS += -lboost_regex-mgw492-mt-d-1_59
}
CONFIG(release, debug|release) {
# release libraries
LIBS += -lboost_regex-mgw492-mt-1_59
# Release variant of Boost binary libraries is compiled with
# disabled run-time assertion (NDEBUG is defined).
# To align binaries with header-only libraries and other headers
# it is possible to define NDEBUG for project release build.
# It is not defined in Qt by default.
DEFINES += NDEBUG
}
I have a problem linking the wxWidget sample application (http://www.wxwidgets.org/docs/tutorials/hello.htm) with is stored in main.cpp. I try to compile and link it using:
g++ `wx-config --cxxflags --libs` main.cpp
The output I get is the following:
/tmp/ccFHWUaX.o: In function `wxCreateApp()':
main.cpp:(.text+0x31): undefined reference to `wxAppConsole::CheckBuildOptions(char const*, char const*)'
/tmp/ccFHWUaX.o: In function `main':
main.cpp:(.text+0x91): undefined reference to `wxEntry(int&, char**)'
/tmp/ccFHWUaX.o: In function `MyFrame::MyFrame(wxString const&, wxPoint const&, wxSize const&)':
main.cpp:(.text+0x1d2): undefined reference to `wxFrameNameStr'
main.cpp:(.text+0x267): undefined reference to `wxEmptyString'
main.cpp:(.text+0x2ea): undefined reference to `wxEmptyString'
main.cpp:(.text+0x366): undefined reference to `wxMenuBar::wxMenuBar()'
main.cpp:(.text+0x3d1): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
main.cpp:(.text+0x3da): undefined reference to `wxStatusLineNameStr'
main.cpp:(.text+0x407): undefined reference to `wxFrame::CreateStatusBar(int, long, int, wxString const&)'
main.cpp:(.text+0x44f): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)'
main.cpp:(.text+0x533): undefined reference to `wxFrame::~wxFrame()'
(and many lines more...)
WxWidgets-2.8 is installed using the ubuntu repository and its libs are located in /usr/lib/x86_64-linux-gnu. I also tried to build specifying the library path with:
-L/usr/lib/x86_64-linux-gnu/
but, this does not change the output. I was blaming multiarch for my problem, but actually only as I don't know how it works exactly.
Can someone tell me how to build the sample correctly?
Thank you
Michael
When using static linking, the libraries must always come after the object files using the symbols from them, otherwise they're simply ignored by the linker as they're not needed at the moment when it first sees them. So us2012 is correct, you need to put wx-config part after your source file.
You could also use shared wxWidgets libraries, then the order wouldn't matter. But it's still a good habit to use the right order, which works for both static and shared libraries, anyhow.
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)