Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined reference to boost::locale:conv::between

Tags:

c++

locale

boost

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.

like image 798
Aleks G Avatar asked Oct 21 '25 13:10

Aleks G


1 Answers

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
like image 66
Some programmer dude Avatar answered Oct 23 '25 03:10

Some programmer dude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!