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.
Related
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
Until some weeks ago, using the boost_regex library I used to compile a C++ file test.cpp using the following command.
g++-4.9 -Wall -O3 -march=native -flto -DNDEBUG -o test \
--std=c++14 test.cpp -lboost_regex -pthread
The compilation was working perfectly. But at some point, I needed to upgrade my OS (more precisely, it was Ubuntu 14.04, now it is Ubuntu 16.04).
I kept my local folders with my data, and I also installed the Boost library again in the new system, including boost_regex.
The Boost version in the new system is 1.58, unfortunately I cannot know which Boost version I was using before because it is now deleted.
I try to compile again the same file in the new system, with the same command as above, and the linker says it cannot find two functions called maybe_assign and construct_init. If I replace the -o test option with just -c (i.e. without linking) then the program is compiled without errors.
More precisely, when I try to do linking I get the following errors (they were extremely long, I hade to shorten using ... dots).
In function `boost::re_detail::perl_matcher<...>::match_match()':
undefined reference to `boost::match_results<...>::maybe_assign(boost::match_results<...> const&)'
In function `bool boost::regex_search<...>(...)':
undefined reference to `boost::re_detail::perl_matcher<...>::construct_init(...)'
In function `boost::re_detail::perl_matcher<...>::match_prefix()':
undefined reference to `boost::match_results<...>::maybe_assign(boost::match_results<...> const&)'
collect2: error: ld returned 1 exit status
I really don't know how this is possible, the libraries seem perfectly installed, nothing seems missing, and the compilation was working with a previous OS installation (then I guess older libraries).
At these point my only guess could be that Boost authors removed such functions? (maybe they are obsolete?). But I didn't find any trace of this on internet. If this is the case, how can I know the boost versions in which such functions are available?
Am I doing any mistake? Do you have any suggestions to investigate about this?
TL;DR use gcc5.
Ununtu 16.04 comes with gcc5 by default. Every C++ library in it is compiled with that compiler.
Now there was an incompatible C++ ABI change between gcc4 and gcc5. It made binaries built from C++ sources with gcc4 incompatible by default with binaries built with gcc5. This incompatibility often manifests itself as a bunch of undefined symbols that reference std::string and/or std::list.
The standard library comes built with a dual ABI to support objects built with older compilers. Other libraries like boost, hovever, don't.
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.
#include <boost/locale/encoding.hpp>
int main()
{
const std::string strutf8("你好,世界");
std::wstring wtrutf16 = boost::locale::conv::to_utf<wchar_t>(strutf8, "UTF-8");
return 0;
}
this is my code, i want to use boost.locale lib in my project on centos 7 64 bit system, i compile the boost library using ./bootstrap and ./b2,i works fine except i static link libboost_locale.a,i compile in console using:
g++ -o locale locale.cpp -static -L ~/Downloads/boost_1_57_0/stage/lib -lboost_system -lboost_filesystem -lboost_locale
the gcc shows the error like this:
/root/Downloads/boost_1_57_0/stage/lib/libboost_locale.a(codepage.o):in fuction ‘boost::locale::conv::impl::uconv_to_utf<wchar_t>::open(char const*, boost::locale::conv::method_type)’:
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0xb0):undefined reference to ‘ucnv_open_50’未定义的引用
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0xcd):undefined reference to ‘ucnv_close_50’未定义的引用
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x146):undefined reference to ‘UCNV_FROM_U_CALLBACK_STOP_50’
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x14e):undefined reference to ‘ucnv_setFromUCallBack_50’
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x16b):undefined reference to ‘UCNV_TO_U_CALLBACK_STOP_50’
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x17b):undefined reference to ‘ucnv_setToUCallBack_50’
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x18f):undefined reference to ‘ucnv_getMaxCharSize_50’
codepage.cpp:(.text._ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE[_ZN5boost6locale4conv4impl12uconv_to_utfIwE4openEPKcNS1_11method_typeE]+0x1a2):undefined reference to ‘ucnv_close_50’
....
i've no idea what happened, i try to install libiconv.a,but i didn't work.
so, would anynoe tell me how to solve this problem.
The symbol name after "undefined reference" belong to ICU4C.
Look like you choose to use ICU4C when compiled the Boost Locale.
There are two solutions:
Add parameter for linking ICU4C library, please visit How To Use ICU for more detail.
Rebuild Boost Locale, set boost.locale.icu=off
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).