Linker errors building libcxx on fresh Ubuntu install - c++

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

Related

undefined reference to `boost::iostreams::zlib::deflated'

I am trying to install the Trans-Proteomic Pipeline found here. I have installed each of the necessary libraries mentioned in the readme, but when I run make all or make install it progresses through much of the compilation, and then errors out with the following message:
undefined reference to `boost::iostreams::zlib::deflated'
The error log is much longer with what seems to be redundant information but it generally looks like this:
/usr/bin/ld: /home/nkho/proj/tpp/release_6-0-0/build/gnu-x86_64-rc28/lib/libpwiz.a(MSDataFile.o): in function `pwiz::msdata::(anonymous namespace)::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)':
MSDataFile.cpp:(.text+0x1cda): undefined reference to `boost::iostreams::zlib::deflated'
/usr/bin/ld: MSDataFile.cpp:(.text+0x1cf8): undefined reference to `boost::iostreams::zlib::default_strategy'
/usr/bin/ld: /home/nkho/proj/tpp/release_6-0-0/build/gnu-x86_64-rc28/lib/libpwiz.a(MSDataFile.o): in function `boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::dispose()':
MSDataFile.cpp:(.text._ZN5boost6detail17sp_counted_impl_pINS_9iostreams16symmetric_filterINS2_6detail20zlib_compressor_implISaIcEEES6_E4implEE7disposeEv[_ZN5boost6detail17sp_counted_impl_pINS_9iostreams16symmetric_filterINS2_6detail20zlib_compressor_implISaIcEEES6_E4implEE7disposeEv]+0x27): undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost6detail17sp_counted_impl_pINS_9iostreams16symmetric_filterINS2_6detail20zlib_compressor_implISaIcEEES6_E4implEE7disposeEv[_ZN5boost6detail17sp_counted_impl_pINS_9iostreams16symmetric_filterINS2_6detail20zlib_compressor_implISaIcEEES6_E4implEE7disposeEv]+0x2f): undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
/usr/bin/ld: /home/nkho/proj/tpp/release_6-0-0/build/gnu-x86_64-rc28/lib/libpwiz.a(MSDataFile.o): in function `boost::iostreams::basic_gzip_compressor<std::allocator<char> >::basic_gzip_compressor(boost::iostreams::gzip_params const&, int)':
MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0x1d7): undefined reference to `boost::iostreams::detail::zlib_base::zlib_base()'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0x1f9): undefined reference to `boost::iostreams::detail::zlib_base::do_init(boost::iostreams::zlib_params const&, bool, void* (*)(void*, unsigned int, unsigned int), void (*)(void*, void*), void*)'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0x337): undefined reference to `boost::iostreams::zlib::best_compression'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0x34e): undefined reference to `boost::iostreams::zlib::best_speed'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0xa51): undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0xa59): undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0xa75): undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
/usr/bin/ld: MSDataFile.cpp:(.text._ZN5boost9iostreams21basic_gzip_compressorISaIcEEC2ERKNS0_11gzip_paramsEi[_ZN5boost9iostreams21basic_gzip_compressorISaIcEEC5ERKNS0_11gzip_paramsEi]+0xa7d): undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
I've seen a variety of other questions with similar messages that mention one should define the path to the boost installation/binaries in the g++ command, but all I am running is make install, so I am not sure where I would specify this.

Facing undefined reference error after upgrading Protobuf

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

Build Peerconnection with WebRTC static library failed

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!

Make utility complains about "undefined reference" when I tried to make TPC-E test [duplicate]

This question already has answers here:
GCC linker can't find standard library?
(4 answers)
Closed 3 years ago.
The problem is compounded by the fact that I am far from programming.
I need to use the TPC-E test. I downloaded the source codes from their website.
There is a miserable and almost meaningless ReadMe.
Here are its contents:
To use the Makefile you must first set the following environment variables
to match your system and compiler requirements:
CXX: path and name of compiler
ex: export CXX=/opt/SUNWspro/bin/CC (C++ compiler on Solaris)
CCFLAGS: compiler options
ex: export CCFLAGS="-g -O"
-g enable debug
-O optimize code
LDFLAGS: linker/loader options
ex: export LDFLAGS="-g"
LIBS: extra libraries to link in
ex: export LIBS="-lpthread"
According to the instructions there, I created the necessary environment variables (I just removed the -g switch from the CCFLAGS variable). After that, I ran the make utility and got more than five thousand lines of errors. Apparently he lacks some libraries. On this my knowledge ends.
Here are some error messages received:
...
/usr/bin/ld: DateTime.o: in function `TPCE::CDateTime::Validate(int, int, int, int, int, int, int)': DateTime.cpp:(.text+0xee): undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
/usr/bin/ld: DateTime.cpp:(.text+0xfd): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: DateTime.cpp:(.text+0x107): undefined reference to `__cxa_allocate_exception'
/usr/bin/ld: DateTime.cpp:(.text+0x117): undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const'
/usr/bin/ld: DateTime.cpp:(.text+0x122): undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: DateTime.cpp:(.text+0x135): undefined reference to `operator delete(void*)'
...
/usr/bin/ld: error.cpp:(.text._ZN4TPCE10CSystemErrD0Ev[_ZN4TPCE10CSystemErrD5Ev]+0x24): undefined reference to `std::exception::~exception()'
/usr/bin/ld: error.cpp:(.text._ZN4TPCE10CSystemErrD0Ev[_ZN4TPCE10CSystemErrD5Ev]+0x31): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: error.o: in function `TPCE::CSystemErr::~CSystemErr()':error.cpp:(.text._ZN4TPCE10CSystemErrD2Ev[_ZN4TPCE10CSystemErrD5Ev]+0x1c): undefined reference to `operator delete(void*)'
...
/usr/bin/ld: locking.cpp:(.text+0x1fb): undefined reference to `operator delete(void*)'
/usr/bin/ld: locking.cpp:(.text+0x202): undefined reference to `std::runtime_error::~runtime_error()'
/usr/bin/ld: locking.cpp:(.text+0x209): undefined reference to `typeinfo for std::runtime_error'
/usr/bin/ld: locking.cpp:(.text+0x211): undefined reference to `__cxa_throw'
/usr/bin/ld: locking.o: in function `TPCE::CMutex::lock()':locking.cpp:(.text+0x246): undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
...
A search on the internet made me think of installing the libboost-all-dev package, but that didn't help. In the end, I gave up - I’m completely incomprehensible to the terminology and I don’t have time to study C ++ programming.
Operating System - Debian 10
Questions: which libraries need to be installed and is there anyone who used these tests, how to adapt them to PostgreSQL?
Full error log (892 230 bytes)
I replaced
export CXX=/usr/bin/gcc
with
export CXX=/usr/bin/c++

CppDB compilation errors

I followed the following steps in order to build CppDB:
svn co http://cppcms.svn.sourceforge.net/svnroot/cppcms/cppdb/trunk cppdb-trunk
cd cppdb-trunk
cmake ~/Desktop/cppdb-trunk
make
make install
Afterwards, I'm trying to compile and run the file example1.cpp from the examples directory.
When I run gcc example1.cpp I get the following errors:
/tmp/ccGWenrv.o: In function main':
example1.cpp:(.text+0x2a): undefined reference tostd::allocator::allocator()'
example1.cpp:(.text+0x42): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
example1.cpp:(.text+0x58): undefined reference tocppdb::session::session(std::__cxx11::basic_string, std::allocator > const&)'
example1.cpp:(.text+0x64): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
example1.cpp:(.text+0x73): undefined reference tostd::allocator::~allocator()'
example1.cpp:(.text+0x91): undefined reference to cppdb::session::operator<<(char const*)'
example1.cpp:(.text+0xa5): undefined reference tocppdb::statement::operator<<(void ()(cppdb::statement&))'
example1.cpp:(.text+0xb4): undefined reference to cppdb::statement::~statement()'
example1.cpp:(.text+0xd2): undefined reference tocppdb::session::operator<<(char const)'
example1.cpp:(.text+0xe6): undefined reference to cppdb::statement::operator<<(void (*)(cppdb::statement&))'
example1.cpp:(.text+0xf5): undefined reference tocppdb::statement::~statement()'
example1.cpp:(.text+0x170): undefined reference to cppdb::statement::statement()'
example1.cpp:(.text+0x18e): undefined reference tocppdb::session::operator<<(char const*)'
example1.cpp:(.text+0x1db): undefined reference to cppdb::statement::operator<<(tm const&)'
example1.cpp:(.text+0x1e8): undefined reference tocppdb::statement::operator<<(char const*)'
example1.cpp:(.text+0x1fd): undefined reference to `cppdb::statement::operator=(cppdb::statement const&)'
etc.
Any suggestions?
Try g++ example1.cpp -lcppdb. You need to link against the C++ run-time library (using g++ instead of gcc takes care of that) and against CppDB itself (the -lcppdb part). If GCC cannot find the -lcppdb library, you'll have to provide the path using -L, and you may have to use LD_LIBRARY_PATH at run time as well.