I'm writing a small demo application (in C on Ubuntu 17.10 with the ICU libraries) that is supposed to convert an array of UTF-8 strings to an array of UChar strings and then sort them according to the locale. However, gcc is giving an error message for one line. Here is the line:
u_strFromUTF8(s[l], 512, NULL, line, -1, &err);
Here are my variable definitions:
FILE *fp;
char *line = NULL;
char lines[512][1000];
UChar *uline = NULL;
size_t len = 0;
ssize_t read;
int l = 0;
int count = 0;
UChar s[512][1000];
And here is the error:
/tmp/cckFKMCm.o: In function `main':
iosort1.c:(.text+0x10c): undefined reference to `u_strFromUTF8_59'
collect2: error: ld returned 1 exit status
Here is the icu-config
line I'm using to build the application:
#!/bin/bash
`icu-config --cc --cflags --cppflags --ldflags` -static -o iosort1 iosort1.c
From what I can tell, ld
is looking for one of the ICU libraries, version 59, and not finding it. Version 57 of the libraries is what comes preinstalled on Ubuntu 17.10.
I've searched the Web and especially Stack Overflow for an answer to this issue. People have asked about many superficially similar problems, but none of the proposed answers has worked for me. Examples: including more libraries in the build script, moving the libraries to the end of the line, adding -static
, and more.
The tactics I have thought of myself include downloading and manually installing version 59.1 of the libraries for Fedora from the ICU site into /usr/local
, and using the path and the library path to point to various combinations of icu-config
versions 57 and 59, and versions 57 and 59 of the ICU libraries. I have also completely deleted version 59 from my disk, and I would have done the same for the preinstalled version 57, except that apparently half of my system depends on it.
Paradoxically, that would seem to be a good sign, because if the preinstalled ICU libraries were broken, half of Ubuntu 17.10 would be too. So it's probable I can get things to work, but how? I don't care which version I end up using, as long as my code will compile.
I'd like to show more of my code, but it's supposed to be one of the "answers in the back of the book" for a class (I'm working with the teacher to produce code samples for the students). I can probably show a little more, though, if you let me know what you want to see.
Thanks for your time and expertise.