C++ 11 threads with clang - c++

I wanted to learn use of C++11 threads to speed up compilation of my language (yes I'm building a compiler :x). The first sample I tried threw several errors with clang (3.3 SVN). It compiled fine under GCC (4.6.3).
I downloaded clang and libc++ from llvm.org's SVN. clang was compiled with GCC (4.6.3) and libc++ was compiled with clang. Both makefiles were generated with CMake.
For clang I followed this guide: http://llvm.org/docs/GettingStarted.html#checkout
For libc++ I followed this guide: http://libcxx.llvm.org/
The piece of code I want to compile (foobar.cpp):
#include <iostream>
#include <thread>
using namespace std;
int main(void) {
thread t1([](void)->void {
cout << "foobar" << endl;
});
}
It compiles fine with clang --std=c++0x -stdlib=libc++ -lpthread foobar.cpp but I get a lot of linker errors:
/tmp/foobar-59W5DR.o: In function `main':
foobar.cpp:(.text+0x21): undefined reference to `std::__1::thread::~thread()'
/tmp/foobar-59W5DR.o: In function `_ZNSt3__16threadC2IZ4mainE3$_0JEvEEOT_DpOT0_':
foobar.cpp:(.text+0x5c): undefined reference to `operator new(unsigned long)'
foobar.cpp:(.text+0x186): undefined reference to `operator delete(void*)'
foobar.cpp:(.text+0x19b): undefined reference to `std::__1::__throw_system_error(int, char const*)'
/tmp/foobar-59W5DR.o: In function `_ZNSt3__114__thread_proxyINS_5tupleIJZ4mainE3$_0EEEEEPvS4_':
foobar.cpp:(.text+0x200): undefined reference to `std::__1::__thread_local_data()'
foobar.cpp:(.text+0x211): undefined reference to `operator new(unsigned long)'
foobar.cpp:(.text+0x23b): undefined reference to `std::__1::__thread_struct::__thread_struct()'
foobar.cpp:(.text+0x31b): undefined reference to `operator delete(void*)'
/tmp/foobar-59W5DR.o: In function `_ZNSt3__110unique_ptrINS_5tupleIJZ4mainE3$_0EEENS_14default_deleteIS3_EEED2Ev':
foobar.cpp:(.text+0x3dd): undefined reference to `operator delete(void*)'
/tmp/foobar-59W5DR.o: In function `main::$_0::operator()() const':
foobar.cpp:(.text+0x3fc): undefined reference to `std::__1::cout'
/tmp/foobar-59W5DR.o: In function `_ZNSt3__110unique_ptrINS_5tupleIJZ4mainE3$_0EEENS_14default_deleteIS3_EEEC2EPS3_':
foobar.cpp:(.text+0x4e9): undefined reference to `std::terminate()'
/tmp/foobar-59W5DR.o: In function `std::__1::__thread_specific_ptr<std::__1::__thread_struct>::reset(std::__1::__thread_struct*)':
foobar.cpp:(.text._ZNSt3__121__thread_specific_ptrINS_15__thread_structEE5resetEPS1_[_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE5resetEPS1_]+0x57): undefined reference to `std::__1::__thread_struct::~__thread_struct()'
foobar.cpp:(.text._ZNSt3__121__thread_specific_ptrINS_15__thread_structEE5resetEPS1_[_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE5resetEPS1_]+0x60): undefined reference to `operator delete(void*)'
/tmp/foobar-59W5DR.o: In function `std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<< <std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)':
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x28): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x1ec): undefined reference to `std::__1::ios_base::getloc() const'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x1fe): undefined reference to `std::__1::ctype<char>::id'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x206): undefined reference to `std::__1::locale::use_facet(std::__1::locale::id&) const'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x272): undefined reference to `std::__1::locale::~locale()'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x294): undefined reference to `std::__1::locale::~locale()'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x378): undefined reference to `std::__1::ios_base::clear(unsigned int)'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x3d0): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x3dc): undefined reference to `__cxa_begin_catch'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x3f9): undefined reference to `std::__1::ios_base::__set_badbit_and_consider_rethrow()'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x403): undefined reference to `__cxa_end_catch'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x424): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x43d): undefined reference to `__cxa_end_catch'
foobar.cpp:(.text._ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc[_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc]+0x466): undefined reference to `std::terminate()'
/tmp/foobar-59W5DR.o: In function `std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)':
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0x38): undefined reference to `std::__1::ios_base::getloc() const'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0x49): undefined reference to `std::__1::ctype<char>::id'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0x55): undefined reference to `std::__1::locale::use_facet(std::__1::locale::id&) const'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0xac): undefined reference to `std::__1::locale::~locale()'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0xbe): undefined reference to `std::__1::locale::~locale()'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0xcd): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)'
foobar.cpp:(.text._ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_[_ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_]+0xdd): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()'
/tmp/foobar-59W5DR.o: In function `std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char)':
foobar.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x215): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)'
foobar.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x389): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()'
foobar.cpp:(.text._ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_[_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_]+0x3a4): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()'
/tmp/foobar-59W5DR.o:(.eh_frame+0x47): undefined reference to `__gxx_personality_v0'
clang-3: error: linker command failed with exit code 1 (use -v to see invocation)
Here are the standard search directories under the two standard libraries.
As result of 'clang -Wp,-v -x c++ - -fsyntax-only' I got this:
I tried clang --std=c++11 -stdlib=libc++ -llibc++ -lpthread -o foobar foobar.cpp but the linker failed again, it does not find libc++. Do I fail on linking to libc++ or is it something more difficult?

You are compiling with clang for C not for C++.
For C use clang
For C++ use clang++
The reason why clang didnt warn you is because you explicitly defined the standard.

Related

Xalan link failure using libraries built from source

I am upgrading one of our libraries to the latest version. The xalan from GitHub at https://github.com/apache/xalan-c. I was able to compile this library successfully using gcc 12. And when I ran make test command, it was all OK. But when used it in my code and it will fail when try to link, I got errors like this (I did check the library search path, both libxalan-c.so and libxalanMsg.so can be found by the ld):
g++ -g -O0 -Werror -Wunused -Wall -D__USE_XOPEN2K8 -D_REENTRANT -D__STL_PTHREADS -std=c++17 -pthread -Wno-parentheses -Wno-nonnull -pipe -lxerces-c -L/rapid/rapid_workspaces/chuhuan/GitHub/xalan-c/build/lib64/ -lxalan-c -lxalanMsg -Lxxxxxxxxx/TargetRTS/ -ldhf
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: linux/TargetRTS/ParamConfig.o: in function `dhf::DataHandlerFactory::initializeXMLLibs()':
xxxxxxxxx/DataHandlerFactory.hh:58: undefined reference to `xalanc_1_12::XalanTransformer::initialize(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DataHandlerFactory.hh:59: undefined reference to `xalanc_1_12::XPathEvaluator::initialize(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::transform(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xxxxxxxxx/DOMImpl.cc:173: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:183: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char16_t const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:184: undefined reference to `xalanc_1_12::XercesDOMWrapperParsedSource::XercesDOMWrapperParsedSource(xercesc_4_0::DOMDocument const*, xalanc_1_12::XercesParserLiaison&, xalanc_1_12::XercesDOMSupport&, xalanc_1_12::XalanDOMString const&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:190: undefined reference to `xalanc_1_12::FormatterToXercesDOM::FormatterToXercesDOM(xercesc_4_0::DOMDocument*, xercesc_4_0::DOMElement*, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:191: undefined reference to `xalanc_1_12::XalanTransformer::XalanTransformer(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:192: undefined reference to `xalanc_1_12::XSLTResultTarget::XSLTResultTarget(xalanc_1_12::FormatterListener&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:192: undefined reference to `xalanc_1_12::XSLTInputSource::XSLTInputSource(char const*, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double*)':
xxxxxxxxx/DOMImpl.cc:237: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:244: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:246: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:248: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:250: undefined reference to `xalanc_1_12::XPathEvaluator::evaluate(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::getSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int*)':
xxxxxxxxx/DOMImpl.cc:298: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:305: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:307: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:309: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:313: undefined reference to `xalanc_1_12::XPathEvaluator::selectSingleNode(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
xxxxxxxxx/DOMImpl.cc:364: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:371: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:373: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:375: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:377: undefined reference to `xalanc_1_12::XPathEvaluator::evaluate(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::serialize(std::ostream&)':
xxxxxxxxx/DOMImpl.cc:486: undefined reference to `xalanc_1_12::XalanStdOutputStream::XalanStdOutputStream(std::ostream&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o):xxxxxxxxx/DOMImpl.cc:490: more undefined references to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)' follow
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::serialize(std::ostream&)':
xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::FormatterToXML::FormatterToXML(xalanc_1_12::Writer&, xalanc_1_12::XalanDOMString const&, bool, int, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, bool, xalanc_1_12::XalanDOMString const&, xalanc_1_12::FormatterListener::eFormat, bool, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:501: undefined reference to `xalanc_1_12::XercesDOMWalker::traverse(xercesc_4_0::DOMNode*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::selectNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xxxxxxxxx/DOMImpl.cc:510: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:517: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:522: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:527: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:528: undefined reference to `xalanc_1_12::XPathEvaluator::selectSingleNode(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
collect2: error: ld returned 1 exit status
my cmake options:
CC=gcc-12.2.0/bin/gcc CXX=gcc-12.2.0/bin/g++ CFLAGS=-O3 CXXFLAGS=-O3 cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=xalan-c/build -DCMAKE_BUILD_TYPE=Release -Dmessage-loader=inmemory -Dtranscoder=default xalan-c
It seems something may be inconsistent with my build options, any idea to fix this?
Thanks very much!
Chunde
Eventually figured out the issue, this was because Xalan need to link to Xercesc, without specifying the path to the version 4.0.0 of Xercesc, it will link to the default version at system path. So I used
-DCMAKE_PREFIX_PATH
variable to set that, the new cmake command looks like this:
CC=gcc-12.2.0/bin/gcc CXX=gcc-12.2.0/bin/g++ CFLAGS=-O3 CXXFLAGS=-O3 cmake -DCMAKE_PREFIX_PATH=xxx/xerces-c_4.0.0/ -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=xalan-c/build -DCMAKE_BUILD_TYPE=Release -Dmessage-loader=inmemory -Dtranscoder=default xalan-c

unable to run mpicc in linux

My code was working fine on windows, now that I am trying to compile on ubuntu 20.4; I am getting this error; I am copying part of the error as there are a lot:
after runing : mpicc C.cpp -o C
usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xda): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xed): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10b): undefined reference to `__cxa_begin_catch'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x117): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_rethrow'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x128): undefined reference to `__cxa_end_catch'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `__gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long)':
C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim[_ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim]+0x20): undefined reference to `operator delete(void*)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `__gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*)':
C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x30): undefined reference to `std::__throw_bad_alloc()'
/usr/bin/ld: C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x40): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o:(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48): undefined reference to `MPI::Win::Free()'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Intercomm::~Intercomm()':
C.cpp:(.text._ZN3MPI9IntercommD0Ev[_ZN3MPI9IntercommD5Ev]+0x29): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Graphcomm::~Graphcomm()':
C.cpp:(.text._ZN3MPI9GraphcommD0Ev[_ZN3MPI9GraphcommD5Ev]+0x29): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Cartcomm::~Cartcomm()':
when I check mpirun --version: I get this : mpirun (Open MPI) 4.0.3
This error:
usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xda): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xed): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10b): undefined reference to `__cxa_begin_catch'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x117): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_rethrow'
/usr/bin/ld: C.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x128): undefined reference to `__cxa_end_catch'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `__gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long)':
C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim[_ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim]+0x20): undefined reference to `operator delete(void*)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `__gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*)':
C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x30): undefined reference to `std::__throw_bad_alloc()'
/usr/bin/ld: C.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x40): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o:(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48): undefined reference to `MPI::Win::Free()'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Intercomm::~Intercomm()':
C.cpp:(.text._ZN3MPI9IntercommD0Ev[_ZN3MPI9IntercommD5Ev]+0x29): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Graphcomm::~Graphcomm()':
C.cpp:(.text._ZN3MPI9GraphcommD0Ev[_ZN3MPI9GraphcommD5Ev]+0x29): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccNx3sbm.o: in function `MPI::Cartcomm::~Cartcomm()':
Because you are compiling with mpicc:
Compiles and links MPI programs written in C
but you should be using in this case mpic++
mpic++ -- Open MPI C++ wrapper compiler

Cannot compile v8 sample code on ubuntu 16.04

I'm trying to run the hello world sample code from the official v8 repo. After reading the docs I could make it work on version 5.8 just as it is described in the wiki. However, I'm interested to explore this using the latest version of v8, but when I do:
g++ -I. -Iinclude samples/hello-world.cc -o hello-world -Wl,--start-group out.gn/x64.release/obj/{libv8_{base,libbase,external_snapshot,libplatform,libsampler},third_party/icu/libicu{uc,i18n},src/inspector/libinspector}.a -Wl,--end-group -lrt -ldl -pthread -std=c++0x
I get the following error:
out.gn/x64.release/obj/libv8_libbase.a(random-number-generator.o): In function `std::__1::__hash_table<unsigned long, std::__1::hash<unsigned long>, std::__1::equal_to<unsigned long>, std::__1::allocator<unsigned long> >::rehash(unsigned long)':
random-number-generator.cc:(.text._ZNSt3__112__hash_tableImNS_4hashImEENS_8equal_toImEENS_9allocatorImEEE6rehashEm[_ZNSt3__112__hash_tableImNS_4hashImEENS_8equal_toImEENS_9allocatorImEEE6rehashEm]+0x34): undefined reference to `std::__1::__next_prime(unsigned long)'
random-number-generator.cc:(.text._ZNSt3__112__hash_tableImNS_4hashImEENS_8equal_toImEENS_9allocatorImEEE6rehashEm[_ZNSt3__112__hash_tableImNS_4hashImEENS_8equal_toImEENS_9allocatorImEEE6rehashEm]+0x111): undefined reference to `std::__1::__next_prime(unsigned long)'
out.gn/x64.release/obj/libv8_libbase.a(platform-linux.o): In function `v8::base::OS::GetSharedLibraryAddresses()':
platform-linux.cc:(.text._ZN2v84base2OS25GetSharedLibraryAddressesEv+0x20f): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
platform-linux.cc:(.text._ZN2v84base2OS25GetSharedLibraryAddressesEv+0x322): undefined reference to `std::__1::__basic_string_common<true>::__throw_length_error() const'
out.gn/x64.release/obj/libv8_libbase.a(platform-linux.o): In function `void std::__1::vector<v8::base::OS::SharedLibraryAddress, std::__1::allocator<v8::base::OS::SharedLibraryAddress> >::__push_back_slow_path<v8::base::OS::SharedLibraryAddress>(v8::base::OS::SharedLibraryAddress&&)':
platform-linux.cc:(.text._ZNSt3__16vectorIN2v84base2OS20SharedLibraryAddressENS_9allocatorIS4_EEE21__push_back_slow_pathIS4_EEvOT_[_ZNSt3__16vectorIN2v84base2OS20SharedLibraryAddressENS_9allocatorIS4_EEE21__push_back_slow_pathIS4_EEvOT_]+0x197): undefined reference to `std::__1::__vector_base_common<true>::__throw_length_error() const'
out.gn/x64.release/obj/libv8_external_snapshot.a(setup-isolate-deserialize.o): In function `v8::internal::SetupIsolateDelegate::SetupInterpreter(v8::internal::interpreter::Interpreter*)': setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0x69): undefined reference to `std::__1::ios_base::getloc() const'
setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0x70): undefined reference to `std::__1::ctype<char>::id' setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0x78): undefined reference to `std::__1::locale::use_facet(std::__1::locale::id&) const'
setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0x91): undefined reference to `std::__1::locale::~locale()' setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0x9d): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)'
setup-isolate-deserialize.cc:(.text._ZN2v88internal20SetupIsolateDelegate16SetupInterpreterEPNS0_11interpreter11InterpreterE+0xa5): undefined reference to `std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()'
out.gn/x64.release/obj/libv8_external_snapshot.a(natives-external.o): In function `void std::__1::vector<v8::internal::Vector<char const>, std::__1::allocator<v8::internal::Vector<char const> > >::__emplace_back_slow_path<char const*, int&>(char const*&&, int&)':
natives-external.cc:(.text._ZNSt3__16vectorIN2v88internal6VectorIKcEENS_9allocatorIS5_EEE24__emplace_back_slow_pathIJPS4_RiEEEvDpOT_[_ZNSt3__16vectorIN2v88internal6VectorIKcEENS_9allocatorIS5_EEE24__emplace_back_slow_pathIJPS4_RiEEEvDpOT_]+0x12c): undefined reference to `std::__1::__vector_base_common<true>::__throw_length_error() const'
out.gn/x64.release/obj/libv8_external_snapshot.a(natives-external.o): In function `void std::__1::vector<v8::internal::Vector<char const>, std::__1::allocator<v8::internal::Vector<char const> > >::__push_back_slow_path<v8::internal::Vector<char const> >(v8::internal::Vector<char const>&&)':
natives-external.cc:(.text._ZNSt3__16vectorIN2v88internal6VectorIKcEENS_9allocatorIS5_EEE21__push_back_slow_pathIS5_EEvOT_[_ZNSt3__16vectorIN2v88internal6VectorIKcEENS_9allocatorIS5_EEE21__push_back_slow_pathIS5_EEvOT_]+0x11a): undefined reference to `std::__1::__vector_base_common<true>::__throw_length_error() const'
out.gn/x64.release/obj/libv8_libsampler.a(sampler.o): In function `v8::sampler::SamplerManager::AddSampler(v8::sampler::Sampler*)': sampler.cc:(.text._ZN2v87sampler14SamplerManager10AddSamplerEPNS0_7SamplerE[_ZN2v87sampler14SamplerManager10AddSamplerEPNS0_7SamplerE]+0x25b): undefined reference to `std::__1::__vector_base_common<true>::__throw_length_error() const'
collect2: error: ld returned 1 exit status
Running the same on the 5.8 branch works just fine. How could I make this work with the latest version?

undefined reference errors when I add boost log dependecies

I am trying to add boost logging functionality.
But I've got a lot of errors with undefined reference.
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::~thread_specific_ptr()':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::get() const':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::reset(boost::log::v2s_mt_nt5::core::implementation::thread_data*)':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `~thread_specific_ptr':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(severity_level.o): In function `void boost::this_thread::at_thread_exit<boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > > >(boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > >)':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(once_block.o): In function `boost::detail::basic_cv_list_entry::wait(boost::detail::timeout)':
D:\c++\boost_1_58_0/./boost/thread/win32/condition_variable.hpp:94: undefined reference to `boost::this_thread::interruptible_wait(void*, boost::detail::timeout)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(thread_id.o): In function `at_thread_exit<boost::log::v2s_mt_nt5::aux::this_thread::(anonymous namespace)::id_storage::deleter>':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
collect2.exe: error: ld returned 1 exit status
My linked libraries looks like this.
My include declarations looks like this
Also my boost include folder is located in main x86_64-w64-mingw32 include folder
Had the same error under Windows 10, Cygwin GCC setup. I had to link boost_thread separately in addition to boost_log and boost_log_setup.
-lboost_log_setup -lboost_log -lboost_thread
I was using BOOST 1.66.

How to solve compilation error when building Dlib code.?

I was tried to run sample Dlib code Using MinGW and Netbeans. But I got compilation error.
Steps Followed:
1.Downloaded Dlib package from Dlib website.
2.Include root folder(Dlib) in c++ Compiler setting and also set -std=c++11 in compiler additional flag.
3.Copy the sample from example of Dlib folder.
4.Compiled.
I got Bellow error when compiling code.Give me simple steps for executing Dlib sample code(for example face_detection_ex code in example in Dlib)
build/Debug/MinGW-Windows/main.o: In function `Z12loadIbugDataN5boost10filesystem4pathE':
D:\NetBeansProjects\SDM/main.cpp:124: undefined reference to `boost::filesystem::path::extension() const'
D:\NetBeansProjects\SDM/main.cpp:133: undefined reference to `boost::filesystem::path::replace_extension(boost::filesystem::path const&)'
build/Debug/MinGW-Windows/main.o: In function `main':
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::m_default_line_length'
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::m_default_line_length'
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
D:\NetBeansProjects\SDM/main.cpp:358: undefined reference to `boost::program_options::options_description::add_options()'
D:\NetBeansProjects\SDM/main.cpp:358: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:360: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:362: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:365: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:366: undefined reference to `boost::program_options::variables_map::variables_map()'
D:\NetBeansProjects\SDM/main.cpp:367: undefined reference to `boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)'
D:\NetBeansProjects\SDM/main.cpp:370: undefined reference to `boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)'
D:\NetBeansProjects\SDM/main.cpp:373: undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
If you are in Linux You need to add libvl.so to your Linker setting.
In a 64-bit system you may find this file in /vlfeat/bin/glnxa64/.