[FIXED] Compiling SunVox examples on Linux

Found a bug? Post it here.
Post Reply
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

[FIXED] Compiling SunVox examples on Linux

Post by Ats »

Hello, I'm trying to compile sunvox_lib/examples/c/ to check if sunvox.so is working on Linux.
I tried on two different computers (i386 and x64) with the same results:

Code: Select all

cp ../../resources/* ./
gcc -m64 -g -c test1.c
gcc -m64 -g -c test2.c
gcc -m64 -g -c test3.c
gcc -m64 -g -c test4.c
gcc -m64 -g -c test5.c
gcc -m64 -g -c test6.c
gcc -m64 -ldl -lm -o test1 test1.o
/usr/bin/ld: test1.o: in function `sv_load_dll2':
/home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:666: undefined reference to `dlopen'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:669: undefined reference to `dlerror'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:676: undefined reference to `dlsym'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:677: undefined reference to `dlsym'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:678: undefined reference to `dlsym'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:679: undefined reference to `dlsym'
/usr/bin/ld: /home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:680: undefined reference to `dlsym'
/usr/bin/ld: test1.o:/home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:681: more undefined references to `dlsym' follow
/usr/bin/ld: test1.o: in function `sv_unload_dll':
/home/ats/sunvox_lib/examples/c/../../headers/sunvox.h:769: undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: all] Error 1
What should I do to make it work? As dynamic linking is already set in the MAKE file:
cp ../../linux/lib_x86/sunvox.so ./
make CFLAGS="-m32" LDFLAGS="-m32 -ldl -lm"
Last edited by Ats on Wed Apr 14, 2021 7:48 pm, edited 1 time in total.
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Compiling SunVox examples on Linux

Post by NightRadio »

It looks like the order of the build options is not correct in these examples. This is important for some compilers.
Please try these scripts instead of the old ones:
sunvox_lib_makefile_update.zip
(1.66 KiB) Downloaded 129 times
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Compiling SunVox examples on Linux

Post by Ats »

Thanks, the compilation now works perfectly with the arguments in that order.
All examples are working on both i386 and x86_64 computers!
Post Reply