linking libphonenumber/C++ - c++

I am trying to statically link my project to a fresh libphonenumber/cpp build (release 8.12.56), and get lots of linker errors involving abseil. Here are the first two:
/usr/bin/ld: ../libphonenumber/cpp/build/libphonenumber.a(phonenumberutil.cc.o): in function `absl::lts_20220623::hash_internal::MixingHashState::MixingHashState()':
phonenumberutil.cc:(.text._ZN4absl12lts_2022062313hash_internal15MixingHashStateC2Ev[_ZN4absl12lts_2022062313hash_internal15MixingHashStateC5Ev]+0xb): undefined reference to `absl::lts_20220623::hash_internal::MixingHashState::kSeed'
/usr/bin/ld: ../libphonenumber/cpp/build/libphonenumber.a(phonenumberutil.cc.o): in function `absl::lts_20220623::hash_internal::MixingHashState::CombineContiguousImpl(unsigned long, unsigned char const*, unsigned long, std::integral_constant<int, 8>)':
phonenumberutil.cc:(.text._ZN4absl12lts_2022062313hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi8EE[_ZN4absl12lts_2022062313hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi8EE]+0x56): undefined reference to `absl::lts_20220623::hash_internal::MixingHashState::CombineLargeContiguousImpl64(unsigned long, unsigned char const*, unsigned long)'
Somewhat similarly named functions do appear in libphonenumber.a, but apparently they do not match. libphonenumber_test runs successfully.
The last version of libphonenumber to successfully link with my project is 8.12.39.
My build environment is out-of-the-box debian buster with a the required libraries (as specified in the README) and default-jre-headless installed. I tried compiling with C++11 and C++17 standard. I also tried a few intermediate versions of libphonenumber, with no success.
g++ version: g++ (Debian 8.3.0-6) 8.3.0
cmake version: cmake version 3.13.4

Related

Boost undefined symbol for architecture arm64

I'm trying to build a project that contains code with boost 1.65.1 required.
I'm on a Mac OS M1 chipset (arm64)
I downloaded boost using homebrew
brew install boost
and the version 1.80.0 was correctly installed.
I complice using gcc g++ (and not clang)
I include the library in my cmake and all the includes are working fine and my IDE is able to find all the function references.
At some part of the code I'm using
boost::this_fiber::sleep_for function,
and at the compilation an error is raised by the linker
Undefined symbols for architecture arm64:
"_boost::fibers::context::wait_until(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l> > > const&)", referenced from:
_void boost::this_fiber::sleep_for<long long, std::ratio<1l, 1000000l> >(std::chrono::duration<long long, std::ratio<1l, 1000000l> > const&) in libTest.a
ld: symbol(s) not found for architecture arm64
in my case I find the boost package and linked all boost libraries.
I even tried by hand to add -lboost_fiber-mt or Boost::fiber and I always end up with the same error.
Do you have any idea why the symbol is undefined ? The same code works perfectly on a ubuntu x86_64.
I tried include the libraries by hand in the make and symbols is always undefined.
Probably not quite the answer you're looking for unfortunately, but I've had the same experience with a brew install, but have had success building the boost libraries myself, downloading from here and following installation instructions here. Hope this is helpful!

errors linking clang-built executable with g++-v6-built boost library

I have a boost regex library built myself with g++ version 6.3.1 on Fedora Linux.
Then I have my own library using the boost regex, built with clang++ 4.0 as shared object.
Building this works fine.
At last I have an executable which links to my library and this produces the following error:
undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform[abi:cxx11](char const*, char const*) const'
Building and linking with g++ only works correctly.
Can this be solved with some commandline argument to clang++?
As nobody seems to have a solution for this, I compiled boost a second time with
./b2 toolset=clang
and now my problems are gone.

icu 54 - undefined reference

Everything worked well with boost1.53, but when with boost 1.46, the project won't compile. I do understand there is no dependency between boost1.46 and icu, but it's weird that the same code could work normally with a higher version boost which relies on icu.
Invoking: GCC C++ Linker
g++ -o "CPPTest" ./worker/statistical_based_extraction.o ./common/utf8/icu_utf8_sequence.o ./common/tokenizer/indo_european_tokenizer.o ./common/features/indo_european_token_shape_feature_extractor.o ./common/crfpp_tagger.o ./crftest.o -lcrfpp -licuuc -lpython2.7
./worker/statistical_based_extraction.o: In function `GetLocale':
/home/tilney/workspace/CPPTest/Debug/../worker/statistical_based_extraction.h:25: undefined reference to `icu_54::Locale::Locale(char const*, char const*, char const*, char const*)'
/home/tilney/workspace/CPPTest/Debug/../worker/statistical_based_extraction.h:25: undefined reference to `icu_54::Locale::~Locale()'
Tried to configure icu with --disable-renaming, no luck.
tilney#tilney:/apps/nlp$ ls /usr/local/lib/libicu
libicudata.so libicui18n.so libicuio.so libicule.so libiculx.so libicutest.so libicutu.so libicuuc.so
libicudata.so.54 libicui18n.so.54 libicuio.so.54 libicule.so.54 libiculx.so.54 libicutest.so.54 libicutu.so.54 libicuuc.so.54
libicudata.so.54.1 libicui18n.so.54.1 libicuio.so.54.1 libicule.so.54.1 libiculx.so.54.1 libicutest.so.54.1 libicutu.so.54.1 libicuuc.so.54.1
Although Boost 1.46 doesn't provide Boost.Locale api, it DOES RELY on icu48, when you use apt-get to install boost, the corresponding icu would also be installed, which conflicts with the hand-installed icu. As for higher version boost, it was hand-installed so it didn't install any additional package.

Can't get googletest running with ubuntu (linker errors)

I've built googletest using make under linux, the resulting files are libgtest.a libgtest_main.a.
I referenced the include files from my application and added the following lib dependencies (in the given order):
-lgtest
-lpthread
However I get the following two linker errors when I try to compile:
more undefined references to `testing::internal::EqFailure(char const*, char const*, testing::internal::String const&, testing::internal::String const&, bool)
undefined reference to `testing::internal::String::ShowCStringQuoted(char const*)
From what I've seen within the googletest source, the EqFailure function is directly implemented within gtest.cc. I don't understand why I should get a linker error here, the other definitions from googletest could obviously also be found (if I remove -lgtest, I get alot of more linker errors).
What am I missing? Thank you in advance.
Make sure you do not accidentally mix your own gtest and the one shipped with ubuntu.
I use cmake to build and got the same errors due to cmake opting for /usr/include over my own custom built version (which is what I linked with).

Building 32-bit FCGI++ binaries in 64-bit environment in Ubuntu 13

Good afternoon.
I'm trying to build 32-bit fcgi++ binaries under my 64-bit env. I configured FCGI++ in the following way:
CC="gcc -m32" ./configure
After typing 'make' I see the some building process and the following errors at the end (snippet is here):
gcc -m32 -shared fcgio.lo -Wl,--rpath -Wl,/home/eotovchits/Downloads/fcgi/fcgi-2.4.1-SNAP-0311112127/libfcgi/.libs -Wl,--rpath -Wl,/usr/local/lib /home/eotovchits/Downloads/fcgi/fcgi-2.4.1-SNAP-0311112127/libfcgi/.libs/libfcgi.so -Wl,-soname -Wl,libfcgi++.so.0 -o .libs/libfcgi++.so.0.0.0
/usr/bin/ld: i386:x86-64 architecture of input file fcgio.lo' is incompatible with i386 output
fcgio.lo: In function__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference tostd::ios_base::Init::~Init()'
...................... a lot of similar lines ...........................
fcgio.lo: In function ~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference tovtable for std::basic_ios >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to std::ios_base::~ios_base()'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference tovtable for std::basic_ios >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to std::ios_base::~ios_base()'
fcgio.lo: In functionfcgi_istream::~fcgi_istream()':
/home/eotovchits/Downloads/fcgi/fcgi-2.4.1-SNAP-0311112127/libfcgi/../include/fcgio.h:120: undefined reference to `operator delete(void*)'
/usr/bin/ld: fcgio.lo: file class ELFCLASS64 incompatible with ELFCLASS32
/usr/bin/ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
I assume that I need some additional 32-bits building environment to make the 32-bits binaries (along w/ all the needed 3rd-party libraries, .a-s and .so-s)
Do you know how can i set up such environment locally along with native 64-bit environment and build my fcgi++ binaries for 32-bits environment?
Thank you.
on Ubuntu you can install the libraries for i386 along the x64 ones by appending":i386" at the end oh the name of the package you want to install (assuming you are using apt-get to install the lib).
here is an example of how to do it:
https://askubuntu.com/questions/60751/is-it-possible-to-have-32-bit-libraries-installed-on-a-64-bit-system
And here how to install the compiler for 32 bits (well the STL and other stuff):
http://en.kioskea.net/faq/1137-compiling-testing-in-32-bit-on-ubuntu-x86-64