Snippets

Johannes P. BA5Bo: Untitled snippet

Created by Johannes P. last modified
# SDL2.framework is in the correct location:
$ ls /Library/Frameworks
AEProfiling.framework       AudioMixEngine.framework    PluginManager.framework     iTunesLibrary.framework
AERegistration.framework    NyxAudioAnalysis.framework  SDL2.framework

# Frameworks direction is included in path (Note: shouldn't actually matter)
$ echo $PATH
/Users/Jo/_UTIL:/Library/Frameworks:/usr/local/lib:/usr/local/include:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

# Source file for a simple sdl2 program
$ ls
sdl2_test.c

# Attempting to compile object code FAILS without -F flag
$ gcc sdl2_test.c -c -o sdl2_test.o -framework SDL2
sdl2_test.c:1:22: fatal error: SDL2/SDL.h: No such file or directory
 #include "SDL2/SDL.h"
                      ^
compilation terminated.

# Attempting to compile object file SUCCEEDS with -F flag
$ gcc sdl2_test.c -c -o sdl2_test.o -framework SDL2 -F /Library/Frameworks
$ ls
sdl2_test.c sdl2_test.o

# Attempting to link object file FAILS without -F flag
$ gcc sdl2_test.o -o sdl2_test -framework SDL2
ld: framework not found SDL2
collect2: error: ld returned 1 exit status

# Attempting to link object file SUCCEEDS with -F flag
$ gcc sdl2_test.o -o sdl2_test -framework SDL2 -F /Library/Frameworks
$ ls
sdl2_test   sdl2_test.c sdl2_test.o

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.