3

I am trying to follow the answer to my previous question and use boost::locale::conv::between to get a UTF-8 string from vector<char> containing UTF-16 data. My code is pretty much as in the answer (with some differences in how I get the char *:

char in[length + 1];
//... populate in with my source data
in[length] = '\0';
std::string out = boost::locale::conv::between((const char*)in, std::string("UTF-8"), std::string("UTF-16"));

This compiles fine, but during linking I get error

In function `boost::locale::conv::between(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::locale::conv::method_type)':
/usr/local/include/boost/locale/encoding.hpp:186: undefined reference to `boost::locale::conv::between(char const*, char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::locale::conv::method_type)'

This doesn't look right to me. On possibility I could think of is that I had boost 1.50 installed, so I installed latest 1.55 release - yet I get the same error.

Community
  • 1
  • 1
Aleks G
  • 56,435
  • 29
  • 168
  • 265

2 Answers2

10

Boost locale is not a header-only library, it has an actual library that you need to link with. Adding following flag to LDFLAGS helps:

-lboost_locale
Shivendra Mishra
  • 638
  • 4
  • 25
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
1

I have encountered the same problem. I think you should use the dynamic library instead of the static library.

user1251216
  • 97
  • 1
  • 1
  • 3