Search code examples
gccstatic-linkingicu

GCC ICU 57 static linking


I am trying to link ICU 57 to my binary file. That does not work even thought (I think at least) I am linking the static lib files. Here is a blunt example:

gcc -static /usr/lib/libicui18n.a /usr/lib/libicuuc.a /usr/lib/libicudata.a /usr/lib/libicule.a /usr/lib/libiculx.a /usr/lib/libicutu.a /usr/lib/libicuuc.a /usr/lib/libicuio.a obj/ex.o obj/msg.o -o bin/ex

This is the error message that I get:

src/msg.c:5: undefined reference to `u_fopen_57'
src/msg.c:9: undefined reference to `u_fgetfile_57'
src/msg.c:10: undefined reference to `u_fgetfile_57'
src/msg.c:11: undefined reference to `u_frewind_57'
src/msg.c:18: undefined reference to `u_fgetc_57'
src/msg.c:17: undefined reference to `u_feof_57'
src/msg.c:25: undefined reference to `u_fclose_57'

Linking the dynamic libs works fine though.


Solution

  • If you can, I'd recommend using pkg-config as I recommended here,

    specifically with pkg-config --static … as explained here