Woodgnome
Woodgnome

Reputation: 2391

Can't compile with ICU library - undefined reference to 'u_strlen_3_6'

Trying to get the ICU library to work with my C-program, so I can lowercase UTF-8 strings. Here's a minimum example that will reproduce the compile error:

main.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unicode/ustring.h>

int main(int argc, char **argv)
{
  UChar test[100] = { 0x41, 0x42, 0x43, 0x20, 0xc6, 0xd8, 0xc5, 0x20, 0xc9, 0x20, 0xc8, 0x20, 0xd1, 0x20, 0xca, 0x20, 0xd6 };
  for (int i = 0; i < u_strlen(test); i++){
    printf("%d\n", i);
  }
}

Makefile

CC = gcc
CFLAGS = -g -O3 -std=c99
GNUCFLAGS = -g -O3 -std=gnu99 -lm

main: obj/main.o
    $(CC) $(CFLAGS) -o bin/main obj/main.o

obj/main.o: src/main.c
    $(CC) $(CFLAGS) -c src/main.c -o obj/main.o

Compiler output

gcc -g -O3 -std=c99 -o bin/main obj/main.o
obj/main.o: In function `main':
~/src/main.c:9: undefined reference to `u_strlen_3_6'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'main' failed
make: *** [main] Error 1

I've tried including ALL the header files listed at http://icu-project.org/apiref/icu4c/ with no luck. Also tried adding -licudata -licui18n -licuio -liculx -licutest -licutu -licuuc to Makefile - same error.

I'm on Debian GNU/Linux 8.5 (jessie) and the following packages are installed:

Any suggestions?

Upvotes: 2

Views: 1622

Answers (1)

FredK
FredK

Reputation: 4084

I think you need to #include <unicode/utypes>. But you should be able to figure out which Unicode include file is needed by searching the header files to find which one has the definition of u_strlen_3_6.

You might also need to add a -I to your CFLAGS parameter in the makefile.

Upvotes: 1

Related Questions