Skip to content

cogl-gles2: Fix undefined references.

orbea requested to merge orbea/cogl:gles2 into cogl-1.22

When building cogl with --enable-gles2 and slibtool (https://dev.midipix.org/cross/slibtool) the build will fail with undefined references.

rdlibtool --tag=CC --mode=link clang -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/libxml2 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -pthread -I/usr/include/libmount -I/usr/include/blkid -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG -Wall -Wcast-align -Wformat -Wformat-security -Werror=uninitialized -Werror=no-strict-aliasing -Werror=empty-body -Werror=init-self -Werror=undef -Werror=declaration-after-statement -Werror=vla -Werror=pointer-arith -Werror=missing-declarations -Werror=maybe-uninitialized -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -g -O2 -no-undefined -version-info 24:3:4 -export-dynamic -export-symbols-regex ^gl* -o libcogl-gles2.la -rpath /usr/local/lib cogl-gles2-api.lo

rdlibtool: lconf: {.name="libtool"}.
rdlibtool: fdcwd: {.fdcwd=AT_FDCWD, .realpath="/tmp/cogl/cogl-gles2"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 34, .st_ino = 275}.
rdlibtool: lconf: openat(AT_FDCWD,"libtool",O_RDONLY,0) = -1 [ENOENT].
rdlibtool: lconf: openat(AT_FDCWD,"../",O_DIRECTORY,0) = 3.
rdlibtool: lconf: fstat(3,...) = 0 {.st_dev = 34, .st_ino = 144}.
rdlibtool: lconf: openat(3,"libtool",O_RDONLY,0) = 4.
rdlibtool: lconf: found "/tmp/cogl/libtool".
rdlibtool: link: ln -s /dev/null .libs/libcogl-gles2.a.disabled
rdlibtool: link: clang .libs/cogl-gles2-api.o -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/libxml2 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -pthread -I/usr/include/libmount -I/usr/include/blkid -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG -Wall -Wcast-align -Wformat -Wformat-security -Werror=uninitialized -Werror=no-strict-aliasing -Werror=empty-body -Werror=init-self -Werror=undef -Werror=declaration-after-statement -Werror=vla -Werror=pointer-arith -Werror=missing-declarations -Werror=maybe-uninitialized -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -g -O2 -shared -fPIC -Wl,--no-undefined -Wl,-soname -Wl,libcogl-gles2.so.20 -o .libs/libcogl-gles2.so.20.4.3 -Wl,--export-dynamic
/usr/bin/ld: .libs/cogl-gles2-api.o: in function `glBindTexture':
/tmp/cogl/cogl-gles2/cogl-gles2-api.c:9: undefined reference to `cogl_gles2_get_current_vtable'
/usr/bin/ld: .libs/cogl-gles2-api.o: in function `glBlendFunc':
/tmp/cogl/cogl-gles2/cogl-gles2-api.c:16: undefined reference to `cogl_gles2_get_current_vtable'
/usr/bin/ld: .libs/cogl-gles2-api.o: in function `glClear':
/tmp/cogl/cogl-gles2/cogl-gles2-api.c:23: undefined reference to `cogl_gles2_get_current_vtable'
/usr/bin/ld: .libs/cogl-gles2-api.o: in function `glClearColor':
/tmp/cogl/cogl-gles2/cogl-gles2-api.c:30: undefined reference to `cogl_gles2_get_current_vtable'
/usr/bin/ld: .libs/cogl-gles2-api.o: in function `glClearStencil':
/tmp/cogl/cogl-gles2/cogl-gles2-api.c:37: undefined reference to `cogl_gles2_get_current_vtable'
/usr/bin/ld: .libs/cogl-gles2-api.o:/tmp/cogl/cogl-gles2/cogl-gles2-api.c:44: more undefined references to `cogl_gles2_get_current_vtable' follow
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
rdlibtool: exec error upon slbt_exec_link_create_library(), line 1446: (see child process error messages).
rdlibtool: < returned to > slbt_exec_link(), line 1868.
make[2]: *** [Makefile:602: libcogl-gles2.la] Error 2
make[2]: Leaving directory '/tmp/cogl/cogl-gles2'
make[1]: *** [Makefile:598: all-recursive] Error 1

This happens because the build uses -no-undefined and then forgot to link with the appropriate libcogl.la. GNU libtool obscures this issue by silently ignoring -no-undefined while slibtool does not.

Merge request reports