3

The following code:

#include <boost/locale.hpp>
int main()
{
    using namespace boost::locale;
    generator gen;
}

Built with the following flags:

g++ -static -static-libstdc++ -pthread main.cpp -lboost_locale -lboost_system -licuuc -licudata -licui18n

Fails to link with the following errors:

(.text+0x16b8): undefined reference to `icu_60::CacheKeyBase::~CacheKeyBase()'
(.text+0x1c8d): undefined reference to `icu_60::UVector64::~UVector64()'
(.text+0x7dc): undefined reference to `icu_60::UCharsTrie::Iterator::~Iterator()'
...hundreds of other undefined symbols
...(the sample code also has boost linking errors, but let's ignore them, as they only appear in my attempt of reproduction; the real code I have issues with has only icu-related link errors)

I'm using Ubuntu 18.04, with both libboost-all-dev and libicu-dev installed from the Ubuntu repositories. I'm probably missing some trivial component/flag/library needed to make it link together, but am unable to find it.

Adrian17
  • 433
  • 2
  • 6
  • 33
  • Seems like libicu and libicu60 are different packages. – Matthieu Brucher Dec 10 '18 at 16:52
  • I also have `libicu60` installed, yes. – Adrian17 Dec 10 '18 at 16:52
  • and libicu60-dev? anyway, that's not the correct command. you are linking against icu, not icu60. – Matthieu Brucher Dec 10 '18 at 16:54
  • well I am guessing it's just a matter of ordering. Could you try this one and report back: `g++ -static -static-libstdc++ -pthread main.cpp -Wl,--start-group -lboost_locale -lboost_system -licuuc -licudata -licui18n -Wl,--end-group` – Adham Zahran Dec 10 '18 at 18:10
  • 1
    @MatthieuBrucher there is no such package as libicu60-dev. libicu60 is the dependency of libicu-dev (version 60). There's nothing wrong here, just slightly confusing package naming scheme. @AdamZahran you were right, switching the order of the `-licuuc -licudata -licui18n` part did the trick. Thank you. – Adrian17 Dec 11 '18 at 19:08
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Matthieu Brucher Dec 11 '18 at 19:31
  • Use `-lboost_locale-mt` to replace `-lboost_locale`. – chyanog Aug 02 '21 at 11:02

0 Answers0