| Summary: | Compiling static library with -arch fails when linking showimage | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | Gabriel Jacobo <gabomdq> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | 1.2.12 | ||
| Hardware: | x86_64 | ||
| OS: | Mac OS X (All) | ||
| Attachments: | Fix for sdl2-config line for static libs under OSX | ||
I'm seeing this in SDL_image's showimage as well as in my own projects...I think I've managed to reduce the problem to the sdl2-config --libs line, that gives me: -L/Users/gabo/ignifuga/dist/osx32/lib /Users/gabo/ignifuga/dist/osx32/lib/libSDL2.a -lm -liconv -Wl,-framework,OpenGL -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit Note that instead of -lSDL2 it's giving out the full path without -l, so it will be statically linked! This in turns makes the static library generation for SDL_ttf (and SDL_image) look something like: libtool: link: ar cru .libs/libSDL2_ttf.a /Users/gabo/ignifuga/dist/osx32/lib/libSDL2.a SDL_ttf.o So, instead of only archiving SDL_ttf.o it's trying to archive libSDL2.a as well...THIS is the actual problem...removing libSDL2.a by hand from the Makefile solves the issue... However, if I apply the fix in sdl2-config (changing /Users/gabo/ignifuga/dist/osx32/lib/libSDL2.a by -lSDL2), the configure script for SDL_image halts at "checking for SDL - version >= 2.0.0..." Created attachment 827 [details]
Fix for sdl2-config line for static libs under OSX
Sorry for the brain fart yesterday, it turns out that sleeping on a problem is always a good idea. Anyway, replacing the whole library path for -lSDL2 actually solves the problem, so this patch should solve the issue. SDL_ttf and SDL_image compile statically without issue now.
I don't think we need that hack anymore, thanks! http://hg.libsdl.org/SDL/rev/6bb657898f55 |
This happens at least in Lion, with CFLAGS="-arch i386" or CFLAGS="-arch x86_64" The workaround I'm using is removing showimage from the Makefile i386: /bin/sh ./libtool --tag=CC --mode=link gcc -I/Users/gabo/ignifuga/dist/osx/include/libpng12 -g -O2 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -I/Users/gabo/ignifuga/dist/osx/include/SDL2 -D_THREAD_SAFE -o showimage showimage.o libSDL2_image.la -L/Users/gabo/ignifuga/dist/osx/lib /Users/gabo/ignifuga/dist/osx/lib/libSDL2.a -lm -liconv -Wl,-framework,OpenGL -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit libtool: link: gcc -I/Users/gabo/ignifuga/dist/osx/include/libpng12 -g -O2 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -I/Users/gabo/ignifuga/dist/osx/include/SDL2 -D_THREAD_SAFE -o showimage showimage.o -Wl,-framework -Wl,OpenGL -Wl,-framework -Wl,ForceFeedback -Wl,-framework -Wl,Cocoa -Wl,-framework -Wl,Carbon -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreAudio -Wl,-framework -Wl,AudioToolbox -Wl,-framework -Wl,AudioUnit ./.libs/libSDL2_image.a -L/Users/gabo/ignifuga/dist/osx/lib /Users/gabo/ignifuga/dist/osx/lib/libSDL2.a -lm -liconv -lobjc ld: warning: ignoring file ./.libs/libSDL2_image.a, file was built for archive which is not the architecture being linked (i386) Undefined symbols for architecture i386: "_IMG_LoadTexture", referenced from: _main in showimage.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status make: *** [showimage] Error 1 x86_64: /bin/sh ./libtool --tag=CC --mode=link gcc -I/opt/local/include/libpng14 -g -O2 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64 -I/Users/gabo/ignifuga/dist/osx/include/SDL2 -D_THREAD_SAFE -static-libgcc -o showimage showimage.o libSDL2_image.la -L/Users/gabo/ignifuga/dist/osx/lib /Users/gabo/ignifuga/dist/osx/lib/libSDL2.a -lm -liconv -Wl,-framework,OpenGL -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit libtool: link: gcc -I/opt/local/include/libpng14 -g -O2 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64 -I/Users/gabo/ignifuga/dist/osx/include/SDL2 -D_THREAD_SAFE -static-libgcc -o showimage showimage.o -Wl,-framework -Wl,OpenGL -Wl,-framework -Wl,ForceFeedback -Wl,-framework -Wl,Cocoa -Wl,-framework -Wl,Carbon -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreAudio -Wl,-framework -Wl,AudioToolbox -Wl,-framework -Wl,AudioUnit ./.libs/libSDL2_image.a -L/Users/gabo/ignifuga/dist/osx/lib /Users/gabo/ignifuga/dist/osx/lib/libSDL2.a -lm -liconv -lobjc ld: warning: ignoring file ./.libs/libSDL2_image.a, file was built for archive which is not the architecture being linked (x86_64) Undefined symbols for architecture x86_64: "_IMG_LoadTexture", referenced from: _main in showimage.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make: *** [showimage] Error 1