Reputation: 121
I have been playing around with the ICU Unicode libraries and I recently encountered some strange linking errors that have stumped me.
I've narrowed the code down to a minimal example which demonstrates the linker errors :
#include <unicode/uchar.h>
#include <unicode/ustdio.h>
#include <unicode/utypes.h>
//#include <unicode/coll.h>
int main(void) {
UFILE *ustdout;
ustdout = u_get_stdout();
UChar32 *ustr1 = L"Ich bin glücklich!";
u_fprintf(ustdout, "%S\n", ustr1);
return(0);
}
On my Linux Mint 19.2 Cinnamon 64-bit system, compiling the above, according to the icu-config output, gives me :
$ gcc c-icu-test-3.c -I/usr/include -licui18n -licuuc -licudata -o c-icu-test-3.bin
/tmp/ccjku7rS.o: In function `main':
c-icu-test-3.c:(.text+0x9): undefined reference to `u_get_stdout_60'
c-icu-test-3.c:(.text+0x34): undefined reference to `u_fprintf_60'
collect2: error: ld returned 1 exit status
According to "icu-config --cc --cflags --cppflags --ldflags-libsonly" , I'm using the correct command line options.
I have tracked the problem down to something to do with the "U_ICU_ENTRY_POINT_RENAME" macro, and, issuing an "find /usr/include/unicode/ -regextype gnu-awk -regex '(..c$)|(..h$)' -exec grep -H -n -P '^#define +U_ICU_ENTRY_POINT_RENAME.*$' {} \;" outputs :
$ find /usr/include/unicode/ -regextype gnu-awk -regex '(.*\.c$)|(.*\.h$)' -exec grep -H -n -P '^#define +U_ICU_ENTRY_POINT_RENAME.*$' {} \;
/usr/include/unicode/uvernum.h:109:#define U_ICU_ENTRY_POINT_RENAME(x) U_DEF2_ICU_ENTRY_POINT_RENAME(x,U_ICU_VERSION_SUFFIX,U_LIB_SUFFIX_C_NAME)
/usr/include/unicode/uvernum.h:113:#define U_ICU_ENTRY_POINT_RENAME(x) U_DEF2_ICU_ENTRY_POINT_RENAME(x,U_ICU_VERSION_SUFFIX)
I have made sure that I have all the necessary header files and libraries. There, though, appears to be some type of version mismatch, but I don't know how to solve it.
Any help would be appreciated.
Thanks,
jdb2
Upvotes: 0
Views: 861