libclipboard missing dependency + buffer overflow error (related to optimization flags)
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:
Ubuntu arm64: I was able to clone and install with script. Built both the hello world example and the plus example with the following without optimization flags. I'm not seeing any crashes after adding -lxcb for the clipboard dep issue you mentioned.
gcc -o main main.c -I/usr/local/include -L/usr/local/lib -lglfw -lGL -lleif -lclipboard -lxcb -lm
Using ubuntu amd64, I got exactly same problem
gcc -o todo main.c -lleif -lglfw -lm -lGL -lclipboard
I used the above command and it resulted into the following 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
using -lxcb allowed to compile but resulted in buffer overflow.
the error I got -
*** buffer overflow detected ***: terminated zsh: IOT instruction (core dumped) ./todo
Ubuntu arm64: I was able to clone and install with script. Built both the hello world example and the plus example with the following without optimization flags. I'm not seeing any crashes after adding
-lxcbfor the clipboard dep issue you mentioned.gcc -o main main.c -I/usr/local/include -L/usr/local/lib -lglfw -lGL -lleif -lclipboard -lxcb -lm
but it get *** buffer overflow detected ***: terminated [1] 431857 IOT instruction (core dumped)