libepoxy icon indicating copy to clipboard operation
libepoxy copied to clipboard

Static build fails on linux

Open bog-dan-ro opened this issue 3 years ago • 2 comments

I tried to build epoxy as a static library (-Ddefault_library=static) but it fails to link:

$ ninja 
[31/56] Compiling C object test/glx_static.p/glx_static.c.o
../test/glx_static.c: In function ‘main’:
../test/glx_static.c:58:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   58 |     Display *dpy = get_display_or_skip();
      |     ^~~~~~~
[40/56] Linking target test/glx_static
FAILED: test/glx_static 
cc  -o test/glx_static test/glx_static.p/glx_static.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group test/libglx_common.a src/libepoxy.a -static -ldl /usr/lib/x86_64-linux-gnu/libX11.so -Wl,--end-group
/usr/bin/ld: src/libepoxy.a(dispatch_common.c.o): in function `get_dlopen_handle':
/home/bogdan/work/gtk/gtk/subprojects/libepoxy/b/../src/dispatch_common.c:312: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libX11.so'
collect2: error: ld returned 1 exit status
[56/56] Linking target test/glx_beginend
ninja: build stopped: subcommand failed.

bog-dan-ro avatar Mar 18 '21 11:03 bog-dan-ro

I sometimes have this problem specifically with meson/ninja. Not sure if this is related to the issue here but I remember having had projects with GNU configure that could be built static, but the meson/ninja way failed.

rubyFeedback avatar May 01 '21 16:05 rubyFeedback

add "static: true" to the dependency lines eg. gl_dep = dependency('gl', required: false, static: true)

m3t4f1v3 avatar Mar 12 '22 02:03 m3t4f1v3