Description
I currently can't run the hello world example in c.
gcc -Wall -Wextra -g -O0 main.c -lglfw -lGL -lleif -lclipboard -lm -o bin/main
Outputs this error:
/usr/bin/ld: /usr/local/lib/libclipboard.a(clipboard_x11.c.o): undefined reference to symbol 'xcb_get_setup'
/usr/bin/ld: /lib/x86_64-linux-gnu/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I can solve it by adding -lxcb
. However, than running the example gives a buffer overflow:
gcc -Wall -Wextra -g -O0 main.c -lglfw -lGL -lleif -lclipboard -lm -lxcb -o bin/main
bin/main
*** buffer overflow detected ***: terminated
I managed to debug the problem and confirm that it is:
1 - It occurs for -O1, -O2 and -O3 but not -O0
2 - It occurs on lf_load_font_asset
at lib.c:21925
and it seems related to a malformed leif_dir
callstak:
lf_init_glfw(WIDTH, HEIGHT, window)
state.theme = lf_default_theme()
(leif.c1689)
theme.font = lf_load_font_asset("inter", "ttf", 24)
(leif.c1822)
strcat(leif_dir, getenv(HOMEDIR))
(leif.c:2192)
If I compile with -O0, it behaves correctly for some reason: