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.
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
I have encountered the same problem. I think you should use the dynamic library instead of the static library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.