WSL 2 on Windows 11. Installed crystal via Linuxbrew.
Attempts to run crystal run hello.cr
yield linker errors:
ted@TedPad-P51:~/Projects/Exploration.git/Crystal$ crystal run hello.cr
/home/linuxbrew/.linuxbrew/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x16): undefined reference to `__libc_csu_fini'
/home/linuxbrew/.linuxbrew/bin/ld: (.text+0x1d): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
Error: execution of command failed with exit status 1: cc "${@}" -o /home/ted/.cache/crystal/crystal-run-hello.tmp -rdynamic -L/home/linuxbrew/.linuxbrew/Cellar/crystal/1.8.2/libexec/../../../../lib -lpcre2-8 -lm -lgc -lpthread -L/home/linuxbrew/.linuxbrew/Cellar/libevent/2.1.12/lib -levent -lrt -lpthread -ldl
ted@TedPad-P51:~/Projects/Exploration.git/Crystal$
Appears to be a Crystal-specific issue, as gcc compiles and links fine when compiling other (C/C++) programs. Not clear what to check or how to debug.
Note that some slightly different errors (and warnings) appear when using --static
:
ted@TedPad-P51:~/Projects/Exploration.git/Crystal$ crystal build --static hello.cr
/home/linuxbrew/.linuxbrew/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/crystal/1.8.2/libexec/../../../../lib/libevent.a(evutil.o): in function `test_for_getaddrinfo_hacks':
evutil.c:(.text+0x1cc): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/linuxbrew/.linuxbrew/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/crystal/1.8.2/libexec/../../../../lib/libevent.a(evutil.o): in function `evutil_getaddrinfo_common_':
evutil.c:(.text+0x1e8b): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/linuxbrew/.linuxbrew/bin/ld: evutil.c:(.text+0x1f60): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/linuxbrew/.linuxbrew/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x16): undefined reference to `__libc_csu_fini'
/home/linuxbrew/.linuxbrew/bin/ld: (.text+0x1d): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
Error: execution of command failed with exit status 1: cc "${@}" -o /home/ted/Projects/Exploration.git/Crystal/hello -rdynamic -static -L/home/linuxbrew/.linuxbrew/Cellar/crystal/1.8.2/libexec/../../../../lib -lpcre2-8 -lm -lgc -lpthread -L/home/linuxbrew/.linuxbrew/Cellar/libevent/2.1.12/lib -levent -lrt -lpthread -ldl
ted@TedPad-P51:~/Projects/Exploration.git/Crystal$
Not sure if that’s helpful or noise.
It feels like there’s something that didn’t get dropped in the right place for a Linuxbrew-based Crystal install, but I can’t be sure.