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)
Related
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'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.
I am taking a compiler design course and I am trying to learn about ANTLR4 with a C++ target.
Well, that's what I went through:
I Wrote the grammar in a file named "ArrayInit.g4"
Compiled it using ANTLR4 tool and the command "antlr4 -Dlanguage=Cpp -o build" and got a bunch of files in the "build/" directory where I added also a simple file containing the main function int main(){return 0;}
Downloaded the C++ runtime and put it in a directory "runtime/"
In this stage I got stuck, I could not compile the .cpp files using the command "g++ -std=c++11 -I ../runtime -o exec *.cpp" and i get the following error messages:
/tmp/cc8VNGfx.o: In function `ArrayInitLexer::ArrayInitLexer(antlr4::CharStream*)':
ArrayInitLexer.cpp:(.text+0xc8): undefined reference to `antlr4::Lexer::Lexer(antlr4::CharStream*)'
ArrayInitLexer.cpp:(.text+0x116): undefined reference to `antlr4::atn::LexerATNSimulator::LexerATNSimulator(antlr4::Lexer*, antlr4::atn::ATN const&, std::vector<antlr4::dfa::DFA, std::allocator<antlr4::dfa::DFA> >&, std::unordered_set<std::shared_ptr<antlr4::atn::PredictionContext>, antlr4::atn::PredictionContextHasher, antlr4::atn::PredictionContextComparer, std::allocator<std::shared_ptr<antlr4::atn::PredictionContext> > >&)'
/tmp/cc8VNGfx.o: In function `ArrayInitLexer::Initializer::Initializer()':
ArrayInitLexer.cpp:(.text+0x376): undefined reference to `antlr4::dfa::Vocabulary::getLiteralName[abi:cxx11](unsigned long) const'
ArrayInitLexer.cpp:(.text+0x3a6): undefined reference to `antlr4::dfa::Vocabulary::getSymbolicName[abi:cxx11](unsigned long) const'
ArrayInitLexer.cpp:(.text+0x4b2): undefined reference to `antlr4::atn::ATNDeserializer::ATNDeserializer()'
ArrayInitLexer.cpp:(.text+0x4d2): undefined reference to `antlr4::atn::ATNDeserializer::deserialize(std::vector<unsigned short, std::allocator<unsigned short> > const&)'
ArrayInitLexer.cpp:(.text+0x4e8): undefined reference to `antlr4::atn::ATN::operator=(antlr4::atn::ATN&&)'
ArrayInitLexer.cpp:(.text+0x4f7): undefined reference to `antlr4::atn::ATN::~ATN()'
ArrayInitLexer.cpp:(.text+0x503): undefined reference to `antlr4::atn::ATN::getNumberOfDecisions() const'
ArrayInitLexer.cpp:(.text+0x551): undefined reference to `antlr4::atn::ATN::getDecisionState(unsigned long) const'
ArrayInitLexer.cpp:(.text+0x598): undefined reference to `antlr4::atn::ATNDeserializer::~ATNDeserializer()'
ArrayInitLexer.cpp:(.text+0x601): undefined reference to `antlr4::atn::ATNDeserializer::~ATNDeserializer()'
/tmp/cc8VNGfx.o: In function `__static_initialization_and_destruction_0(int, int)':
ArrayInitLexer.cpp:(.text+0x6ec): undefined reference to `antlr4::atn::ATN::ATN()'
ArrayInitLexer.cpp:(.text+0x701): undefined reference to `antlr4::atn::ATN::~ATN()'
ArrayInitLexer.cpp:(.text+0xee6): undefined reference to `antlr4::dfa::Vocabulary::Vocabulary(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
ArrayInitLexer.cpp:(.text+0xefb): undefined reference to `antlr4::dfa::Vocabulary::~Vocabulary()'
/tmp/cc8VNGfx.o: In function `antlr4::Lexer::~Lexer()':
ArrayInitLexer.cpp:(.text._ZN6antlr45LexerD2Ev[_ZN6antlr45LexerD5Ev]+0xf): undefined reference to `vtable for antlr4::Lexer'
ArrayInitLexer.cpp:(.text._ZN6antlr45LexerD2Ev[_ZN6antlr45LexerD5Ev]+0x1d): undefined reference to `vtable for antlr4::Lexer'
ArrayInitLexer.cpp:(.text._ZN6antlr45LexerD2Ev[_ZN6antlr45LexerD5Ev]+0x7d): undefined reference to `antlr4::TokenSource::~TokenSource()'
ArrayInitLexer.cpp:(.text._ZN6antlr45LexerD2Ev[_ZN6antlr45LexerD5Ev]+0x89): undefined reference to `antlr4::Recognizer::~Recognizer()'
/tmp/cc8VNGfx.o: In function `void __gnu_cxx::new_allocator<antlr4::dfa::DFA>::construct<antlr4::dfa::DFA, antlr4::atn::DecisionState*, unsigned long&>(antlr4::dfa::DFA*, antlr4::atn::DecisionState*&&, unsigned long&)':
ArrayInitLexer.cpp:(.text._ZN9__gnu_cxx13new_allocatorIN6antlr43dfa3DFAEE9constructIS3_JPNS1_3atn13DecisionStateERmEEEvPT_DpOT0_[_ZN9__gnu_cxx13new_allocatorIN6antlr43dfa3DFAEE9constructIS3_JPNS1_3atn13DecisionStateERmEEEvPT_DpOT0_]+0x60): undefined reference to `antlr4::dfa::DFA::DFA(antlr4::atn::DecisionState*, unsigned long)'
/tmp/cc8VNGfx.o: In function `void std::_Construct<antlr4::dfa::DFA, antlr4::dfa::DFA>(antlr4::dfa::DFA*, antlr4::dfa::DFA&&)':
ArrayInitLexer.cpp:(.text._ZSt10_ConstructIN6antlr43dfa3DFAEJS2_EEvPT_DpOT0_[_ZSt10_ConstructIN6antlr43dfa3DFAEJS2_EEvPT_DpOT0_]+0x44): undefined reference to `antlr4::dfa::DFA::DFA(antlr4::dfa::DFA&&)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x38): undefined reference to `antlr4::Recognizer::getTokenTypeMap[abi:cxx11]()'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x40): undefined reference to `antlr4::Recognizer::getRuleIndexMap[abi:cxx11]()'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x48): undefined reference to `antlr4::Recognizer::getTokenType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x60): undefined reference to `antlr4::Recognizer::getErrorHeader[abi:cxx11](antlr4::RecognitionException*)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x68): undefined reference to `antlr4::Recognizer::getTokenErrorDisplay[abi:cxx11](antlr4::Token*)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x70): undefined reference to `antlr4::Recognizer::addErrorListener(antlr4::ANTLRErrorListener*)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x78): undefined reference to `antlr4::Recognizer::removeErrorListener(antlr4::ANTLRErrorListener*)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x80): undefined reference to `antlr4::Recognizer::removeErrorListeners()'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x88): undefined reference to `antlr4::Recognizer::getErrorListenerDispatch()'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x90): undefined reference to `antlr4::Recognizer::sempred(antlr4::RuleContext*, unsigned long, unsigned long)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0x98): undefined reference to `antlr4::Recognizer::precpred(antlr4::RuleContext*, int)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0xa0): undefined reference to `antlr4::Recognizer::action(antlr4::RuleContext*, unsigned long, unsigned long)'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0xa8): undefined reference to `antlr4::Recognizer::getState() const'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0xb8): undefined reference to `antlr4::Lexer::getInputStream()'
/tmp/cc8VNGfx.o:(.data.rel.ro._ZTV14ArrayInitLexer[_ZTV14ArrayInitLexer]+0xc0): undefined reference to `antlr4::Lexer::setInputStream(antlr4::IntStream*)'
I am totaly new to C++ and I am skipping a basic idea maybe.
Edit1: I am using Linux
Edit2:
When I execute the commande antlr4 -Dlanguage=Cpp -o build I get a bunch of .cpp and .h files as: ArrayInitLexer.h and many of them include antlr4-runtime.h .This header file is present in the runtime/ folder which by it self includes many other header files in the same directory (.i.e runtime/) that contains .h and .cpp files (I see no .a or .so files).
You can find the runtime here under the C++ target section or directly from here
Your compile command doesn't look quite right.
Note that g++ takes an uppercase -L switch to specify a location to look for libraries, and a lowercase -l to specify the filename of a library to link, not including a lib prefix and the file suffix. Since in at least the version I see, antlr provides a "libantlr.a", this would be -l antlr.
Also, the library should be given after your program source or object file(s), because in most cases the linker decides what pieces of libraries to include based on whether they provide any symbols it knows are needed by what it has seen so far.
So I'm not sure if this will solve all the problems, but a step forward would be:
g++ -std=c++11 -Wall -Wextra *.cpp -L ../runtime -l antlr -o exec
I've also taken the liberty of adding the -W flags to enable a default set of compiler warnings, which is a must when writing new C++ code, whether you're new to the language or not.
I'm trying to cross compile from linux to windows using boost. I've already cross-compiled boost and I do have the DLL, but when I'm linking, I'm getting several undefined references :
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x170): undefined reference to `boost::asio::io_service::io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x1b7): undefined reference to boost::asio::ip::address_v4::from_string(std::__cxx11::basic_string, std::allocator > const&)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x1c7): undefined reference to boost::asio::ip::address::address(boost::asio::ip::address_v4 const&)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x54e): undefined reference to `boost::asio::io_service::~io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x5c0): undefined reference to `boost::asio::io_service::~io_service()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text+0x97e): undefined reference to `boost::asio::io_service::run()'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text$_ZN5boost4asio2ip14basic_endpointINS1_3tcpEEC1ERKNS1_7addressEt[_ZN5boost4asio2ip14basic_endpointINS1_3tcpEEC1ERKNS1_7addressEt]+0x2a): undefined reference to boost::asio::ip::detail::endpoint::endpoint(boost::asio::ip::address const&, unsigned short)'
src/client/CommunicationHandler.o:CommunicationHandler.cpp:(.text$_ZN5boost4asio2ip16resolver_serviceINS1_3tcpEE7destroyERSt10shared_ptrIvE[_ZN5boost4asio2ip16resolver_serviceINS1_3tcpEE7destroyERSt10shared_ptrIvE]+0x20): undefined reference to boost::asio::detail::resolver_service_base::destroy(std::shared_ptr&)'
...etc
Why does the symbols are not in the DLL? What shall I do to make it link properly?
this make it works
#ifndef BOOST_SYSTEM_USE_LIB
# define BOOST_SYSTEM_USE_LIB
#endif
Hi I'm trying to use gnuplot-iostream, at the minute I'm just trying to get the code here working. When I try to combile I get errors in the linker saying:
In function `stream<int, boost::iostreams::file_descriptor_flags>':
/usr/include/boost/iostreams/stream.hpp:130: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(int, boost::iostreams::file_descriptor_flags)'
In function `boost::iostreams::file_descriptor_sink boost::iostreams::detail::wrap<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink const&, boost::disable_if<boost::iostreams::is_std_io<boost::iostreams::file_descriptor_sink>, void>::type*)':
/usr/include/boost/iostreams/detail/wrap_unwrap.hpp:53: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'
In function `concept_adapter':
/usr/include/boost/iostreams/detail/adapter/concept_adapter.hpp:67: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'
/usr/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'
In function `long boost::iostreams::detail::write_device_impl<boost::iostreams::output>::write<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, boost::iostreams::char_type_of<boost::iostreams::file_descriptor_sink>::type const*, long)':
/usr/include/boost/iostreams/write.hpp:121: undefined reference to `boost::iostreams::file_descriptor::write(char const*, long)'
In function `void boost::iostreams::detail::close_impl<boost::iostreams::closable_tag>::close<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, std::_Ios_Openmode)':
/usr/include/boost/iostreams/close.hpp:224: undefined reference to `boost::iostreams::file_descriptor::close()'
In function `std::fpos<__mbstate_t> boost::iostreams::detail::seek_device_impl<boost::iostreams::any_tag>::seek<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, long, std::_Ios_Seekdir, std::_Ios_Openmode)':
/usr/include/boost/iostreams/seek.hpp:137: undefined reference to `boost::iostreams::file_descriptor::seek(long, std::_Ios_Seekdir)'
collect2: ld returned 1 exit status
Note I have boost installed and have previously compiled programs that use iostream.
Any help massively appreciated. Thanks
Ruling out the obvious... are you compiling with g++ -lboost_iostreams? If you can share some information about how the compiler and linker are being invoked it will make it easier to answer your question.
Run into exact problem when tried to use g++ with gnuplot-iostream library.
g++ prog.cpp -L/usr/lib -lboost_filesystem -lboost_system -lboost_iostreams
Resolved the issue for me - the code were compiled successfully with no errors.