Glib static build: iconv cannot be found

Hey there,

When building glib I keep running into problems with ninja not able to find libiconv.

Here’s what I’m doing:

$ meson _build -Ddefault_library=static -Dselinux=disabled -Dc_args="-g -O2 -I/usr/local/include" -Dc_link_args="-s -L/usr/local/lib -L/usr/lib64" -Diconv=external
...
$ ninja -C _build
ninja: Entering directory `_build'
[309/1221] Generating tmpsample.xml with a custom command
FAILED: glib/tests/tmpsample.xml
/home/ec2-user/glib-2.68.1/_build/glib/gtester -k --quiet --i-know-this-is-deprecated -o glib/tests/tmpsample.xml --test-arg=--gtester-selftest /home/ec2-user/glib-2.68.1/_build/glib/gtester
/home/ec2-user/glib-2.68.1/_build/glib/gtester: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
[311/1221] Compiling C object glib/tests/utils.p/utils.c.o
ninja: build stopped: subcommand failed.

I also tried using libc:

$ meson _build -Ddefault_library=static -Dselinux=disabled -Dc_args="-g -O2 -I/usr/local/include" -Dc_link_args="-s -L/usr/local/lib -L/usr/lib64" -Diconv=libc
...
$ ninja -C _build
ninja: Entering directory `_build'
[1/1011] Linking target glib/tests/private
FAILED: glib/tests/private
cc  -o glib/tests/private glib/tests/private.p/private.c.o -L/usr/local/lib -L/usr/lib64 -Wl,--as-needed -Wl,--no-undefined -s -Wl,--start-group glib/libglib-2.0.a -lm -pthread /usr/lib64/libpcre.so -Wl,--end-group
glib/libglib-2.0.a(gconvert.c.o): In function `try_conversion':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:169: undefined reference to `libiconv_open'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:279: undefined reference to `libiconv'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv_close':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:302: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
[2/1011] Linking target glib/gtester
FAILED: glib/gtester
cc  -o glib/gtester glib/gtester.p/gtester.c.o -L/usr/local/lib -L/usr/lib64 -Wl,--as-needed -Wl,--no-undefined -s -Wl,--start-group glib/libglib-2.0.a /usr/lib64/libpcre.so -pthread -lm -Wl,--end-group
glib/libglib-2.0.a(gconvert.c.o): In function `try_conversion':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:169: undefined reference to `libiconv_open'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:279: undefined reference to `libiconv'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv_close':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:302: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
[3/1011] Linking target glib/tests/1bit-emufutex
FAILED: glib/tests/1bit-emufutex
cc  -o glib/tests/1bit-emufutex glib/tests/1bit-emufutex.p/1bit-mutex.c.o -L/usr/local/lib -L/usr/lib64 -Wl,--as-needed -Wl,--no-undefined -s -Wl,--start-group glib/libglib-2.0.a -lm -pthread /usr/lib64/libpcre.so -Wl,--end-group
glib/libglib-2.0.a(gconvert.c.o): In function `try_conversion':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:169: undefined reference to `libiconv_open'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:279: undefined reference to `libiconv'
glib/libglib-2.0.a(gconvert.c.o): In function `g_iconv_close':
/home/ec2-user/glib-2.68.1/_build/../glib/gconvert.c:302: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I manually compiled and installed libiconv-1.16 before attempting to build glib.

It looks like using -lpthread fixed this.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.