1

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.

  • Did you install v59 before or after this problem presented itself? If so, how? – rici Oct 26 '17 at 00:00
  • You have not completely deleted version 59 from your system, otherwise you wouldn't get that undefined reference. The `icu-config` executable, and/or a few header files are still version 59. Check the version of `icu-config`, and if there's a verbose option, see if that shows which header files get included. –  Oct 26 '17 at 00:10
  • I believe I initially installed v59 before the problem occurred. I installed it by untarring the archive from the ICU site, and then manually copying the files in the archive to the filesystem in a way that mirrored the archive. For example, I copied `/home/foo/icu/usr/local/include/*` to `/usr/local/include`. – Ron Hale-Evans Oct 26 '17 at 00:13
  • @Evert icu-config --version shows 57.1. Don't see an option to show included header files, but will keep working on it. – Ron Hale-Evans Oct 26 '17 at 00:18
  • @Evert I've already deleted all the files in `/usr/local/include/unicode` and associated v59 files in `/usr/local/*` a couple of times now, but I keep getting the same error. Spot-check comparison with `/usr/include/unicode` shows the files are different. The icu-config I'm running is v57 as well. What's left? I don't want to have to do a clean reinstall of Ubuntu. – Ron Hale-Evans Oct 26 '17 at 01:25
  • I suggest uninstalling all versions of ICU and then reinstalling the version you want. The hand patching confused things. You might need to Greg through the system to make sure everything is truly gone before doing the reinstall. – Jonathan Leffler Oct 26 '17 at 02:09
  • As I mentioned, half of Ubuntu depends on ICU 57 (the built-in one), so uninstalling it would wreak havoc with my system. It would actually be easier to do a clean reinstall of Ubuntu. – Ron Hale-Evans Oct 26 '17 at 02:55
  • By the way, I've already tried to force use of ICU 59 without much luck, but it seems if I could do this, it would be less disruptive and time-consuming than a clean reinstall of the OS. – Ron Hale-Evans Oct 26 '17 at 04:45
  • I was able to show that running Ubuntu from a clean, bootable USB drive would enable me to compile and run my demo app without errors, so I am grudgingly reinstalling the OS -- but less grudgingly than if I hadn't experimented. – Ron Hale-Evans Oct 26 '17 at 21:32
  • After the OS reinstall, I tried compiling the demo program from my Dropbox copy. I got the same error, except it was looking for the version 57 libraries. I cloned the repo in git (which I had done on the USB drive -- the files were in both GitHub and Dropbox), and it worked again. So it worked twice with git and not at all with Dropbox, either on my old or new installation. Is Dropbox corrupting something? Maybe I could have saved the bother of the reinstallation if I had just done a fresh git clone. – Ron Hale-Evans Oct 27 '17 at 02:35

0 Answers0