I want to enable my program to output Greek letters. I’ve got ICU installed and linked up, but I can’t figure out how to print my Unicode string to standard output. Here’s some simple code:
#include <unicode/unistr.h>
#include <unicode/ustring.h>
#include <unicode/ustream.h>
#include <iostream>
int main() {
UnicodeString mystr("αβγ");
std::cout << mystr << std::endl;
}
Compiling with: g++ ./ctest.cpp -licui18n -licuuc -licudata -lpthread -lm yields the following error:
ctest.cpp:(.text+0x27): undefined reference to `icu_46::operator<<(std::basic_ostream >&, icu_46::UnicodeString const&)’
collect2: ld returned 1 exit status
ICU’s documentation is difficult for a noob like me, and it’s especially sparse for ustream.h, which I think is the key to what I’m trying to do. Any help would be appreciated (especially if anyone would like to write a more user-friendly guide to ICU!).
Use
-licuioflag, since io operations for ICU are in this library.http://userguide.icu-project.org/howtouseicu