Cglm not linked to libm?

I tried to use cglm but ran into an error. I can reproduce it by making a nixos-26.05 shell with the packages:
cglm
gcc
pkg-config

a c file:

#include <cglm/cglm.h>

int main(void) { }

and compile:
gcc test.c -o test -lm $(pkg-config --cflags --libs cglm)

Then I get:

$ ./test 
./test: Relink `/nix/store/bk6476a3w666qxb02gl5zgscyzn24jp4-cglm-0.9.6/lib/libcglm.so.0' with `/nix/store/57iz36553175g3178pvxjij8z5rcsd4n-glibc-2.42-61/lib/libm.so.6' for IFUNC symbol `sinf'
Segmentation fault         (core dumped) ./test

$ ldd /nix/store/bk6476a3w666qxb02gl5zgscyzn24jp4-cglm-0.9.6/lib/libcglm.so.0
	linux-vdso.so.1 (0x00007ffff7fc2000)
	libc.so.6 => /nix/store/57iz36553175g3178pvxjij8z5rcsd4n-glibc-2.42-61/lib/libc.so.6 (0x00007ffff7c00000)
	/nix/store/57iz36553175g3178pvxjij8z5rcsd4n-glibc-2.42-61/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fc4000)

Am I missing something or is this a bug in the cglm package?

I believe you have found a bug, though it shouldn’t stop you from using cglm as a header-only library. Just remove the --libs.

1 Like