Satic Linking And Me.


clone

Still Fresh
Joined
Feb 24, 2004
Messages
78
Location
England
Website
www.clonestyle.com
~EDIT~
Problem resolved. I just switched to using open2x... As for the other platforms, I just need to link with the entire dependency tree, but I only intend on linking statically for gp2x compiles anyway.
~~~~~


I'm running Gentoo linux and I have a build environment that lets me compile for linux, windows and gp2x targets in a sane way. However, whenever -static is thrown into the mix, things stop working. This applies to compiling for all above mentioned targets. Perhaps I am doing something wrong, perhaps there is a fundamental flaw with my system... I do not know.

I decided a fun thing to do would be to go back to the basics. I wrote a program that does nothing but write text via printf(); It could compile statically just fine for all 3 target platforms. However soon as I include SDL into things, static compiling always fails.

Okay, time for some examples I guess.

This is a line that compiles a program fine for the linux (self) target.
gcc index.c -I/usr/include `sdl-config --static-libs` `sdl-config --cflags` -Wall -L/usr/lib -lSDL -lgcc -o bin_linux

works fine.

but soon as I change it slightly
gcc index.c -I/usr/include `sdl-config --static-libs` `sdl-config --cflags` -Wall -L/usr/lib -static -lSDL -lgcc -o bin_linux

CODE

clone@lokke ~/code/c/sdl/igs $ ./index.c
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_DeleteDevice':
(.text+0x3e8): undefined reference to `dlclose'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_Available':
(.text+0x420): undefined reference to `dlopen'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_Available':
(.text+0x466): undefined reference to `dlvsym'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_Available':
(.text+0x47d): undefined reference to `dlsym'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_Available':
(.text+0x4fa): undefined reference to `dlclose'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_Available':
(.text+0x52c): undefined reference to `dlclose'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_CreateDevice':
(.text+0x565): undefined reference to `dlopen'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_CreateDevice':
(.text+0x5ab): undefined reference to `dlvsym'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_CreateDevice':
(.text+0x5c2): undefined reference to `dlsym'
/usr/lib/libSDL.a(SDL_alsa_audio.o): In function `Audio_CreateDevice':
(.text+0x67b): undefined reference to `dlclose'
/usr/lib/libSDL.a(SDL_svgavideo.o): In function `SVGA_FlipHWSurface':
(.text+0x1da): undefined reference to `vga_setdisplaystart'
/usr/lib/libSDL.a(SDL_svgavideo.o): In function `SVGA_FlipHWSurface':
(.text+0x1fb): undefined reference to `vga_waitretrace'
/usr/lib/libSDL.a(SDL_svgavideo.o): In function `SVGA_VideoQuit':
(.text+0x229): undefined reference to `keyboard_close'
{snip!}



These errors go on for several screens....

Not being able to compile statically is perfectly fine for the linux and windows targets, however for the GP2X it is an issue as it means I am not able to make use of the HW accelerated sdl! I suppose if worse came to worse I could use an emulated windows install on my computer to make the gp2x compile... But that would be to admit defeat!

Here are the errors that occur from my gp2x compile line. (compiled verbosely)

arm-gp2x-linux-gcc ./index.c -v -static -g -D_REENTRANT -I/gp2xsdk/Tools/arm-gp2x-linux/include/ -I/gp2xsdk/Tools/arm-gp2x-linux/include/SDL/ -lSDL -o bin_gp2x.gpe

CODE

Reading specs from /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/specs
Configured with: /gp2xsdk/Tools/src/gcc-3.4.6/configure --prefix=/gp2xsdk/Tools --includedir=/gp2xsdk/Tools/arm-gp2x-linux/include --host=i386-linux --target=arm-gp2x-linux --build=i386-linux --program-prefix=arm-gp2x-linux- --with-cpu=arm9tdmi --with-headers=/gp2xsdk/Tools/kernel/linux-2.4.25-gp2x/include --enable-shared --disable-nls --disable-libstdcxx-pch --without-fp --with-softfloat-support=internal
Thread model: posix
gcc version 3.4.6
/gp2xsdk/Tools/libexec/gcc/arm-gp2x-linux/3.4.6/cc1 -quiet -v -I/gp2xsdk/Tools/arm-gp2x-linux/include/ -I/gp2xsdk/Tools/arm-gp2x-linux/include/SDL/ -D__ARM_ARCH_4T__ -D_REENTRANT ./index.c -quiet -dumpbase index.c -mcpu=arm9tdmi -auxbase index -g -version -o /tmp/cc1iXmsx.s
ignoring duplicate directory "/gp2xsdk/Tools/arm-gp2x-linux/include/"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/gp2xsdk/Tools/arm-gp2x-linux/include/SDL/
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/include
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/sys-include
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/include
End of search list.
GNU C version 3.4.6 (arm-gp2x-linux)
compiled by GNU C version 4.1.2 (Gentoo 4.1.2).
GGC heuristics: --param ggc-min-expand=90 --param ggc-min-heapsize=112649
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/bin/as -mcpu=arm9tdmi -o /tmp/ccelv4zY.o /tmp/cc1iXmsx.s
/gp2xsdk/Tools/libexec/gcc/arm-gp2x-linux/3.4.6/collect2 -Bstatic -dynamic-linker /lib/ld-linux.so.2 -X -m armelf_linux -p -o bin_gp2x.gpe /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib/crt1.o /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib/crti.o /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/crtbegin.o -L/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6 -L/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib /tmp/ccelv4zY.o -lSDL --start-group -lgcc -lgcc_eh -lc --end-group /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/crtend.o /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib/crtn.o
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/bin/ld: ERROR: /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/libgcc.a(_udivsi3.oS) uses hardware FP, whereas bin_gp2x.gpe uses software FP
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/bin/ld: failed to merge target specific data of file /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/libgcc.a(_udivsi3.oS)
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/bin/ld: ERROR: /gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/libgcc.a(_divsi3.oS) uses hardware FP, whereas bin_gp2x.gpe uses software FP
{error repeats like this for a long time, then changes to the other pattern from before...}
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib/libSDL.a(SDL_dmaaudio.o): In function `DMA_WaitAudio':
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:161: undefined reference to `__nesf2'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:165: undefined reference to `__floatsisf'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:165: undefined reference to `__subsf3'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:165: undefined reference to `__fixsfsi'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:165: undefined reference to `__floatsisf'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:165: undefined reference to `__addsf3'
/gp2xsdk/Tools/lib/gcc/arm-gp2x-linux/3.4.6/../../../../arm-gp2x-linux/lib/libSDL.a(SDL_dmaaudio.o): In function `DMA_PlayAudio':
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:214: undefined reference to `__nesf2'
/home/darius/gp2x/sdl/SDL-1.2.9/src/audio/dma/SDL_dmaaudio.c:215: undefined reference to `__addsf3'
{snip}



Please note it does not seem to matter if I compile and link with GCC or compile with gcc then link later with ld, soon as I tell ld to do it statically with -aarchive, -Bstatic or whatever, things go crazy.

If anyone could help I'd be greatful!
 
Top