The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL Makefile help !!
shenakan


Joined: 23 Sep 2009
Posts: 1
I use SDL 1.2 I would like to compile my program with static lib. So what is wrong with my makefile ?
Code:
CC=g++

FLAGS= -Wall -O3

all:
   make -f Makefile `uname`

export
objects: main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o

Darwin:
   make objects 'DEFINES=-DMACOSX'
   $(CC) $(FLAGS) -o evolution  main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

.c.o:
   $(CC) $(DEFINES) $(FLAGS) -c $*.c -I.

.cpp.o:
   $(CXX) $(DEFINES) $(FLAGS) -c $*.cpp -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

clean:
   -rm *.o

CC=g++

FLAGS= -Wall -O3

all:
   make -f Makefile `uname`

export
objects: main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o

Darwin:
   make objects 'DEFINES=-DMACOSX'
   $(CC) $(FLAGS) -o evolution  main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

.c.o:
   $(CC) $(DEFINES) $(FLAGS) -c $*.c -I.

.cpp.o:
   $(CXX) $(DEFINES) $(FLAGS) -c $*.cpp -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

clean:
   -rm *.o




Code:

Undefined symbols:
  "_IORegisterForSystemPower", referenced from:
      _QZ_RegisterForSleepNotifications in libSDL.a(SDL_QuartzEvents.o)
  "_ExitMovies", referenced from:
      _QZ_FreeHWYUV in libSDL.a(SDL_QuartzYUV.o)
  "_HideMenuBar", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_IOCreatePlugInInterfaceForService", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_CGLSetParameter", referenced from:
      _QZ_SetupOpenGL in libSDL.a(SDL_QuartzGL.o)
      _QZ_SetupOpenGL in libSDL.a(SDL_QuartzGL.o)
  "_SetIdentityMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_IOMasterPort", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_IOAllowPowerChange", referenced from:
      _QZ_SleepNotificationHandler in libSDL.a(SDL_QuartzEvents.o)
  "_AudioOutputUnitStop", referenced from:
      _Core_CloseAudio in libSDL.a(SDL_coreaudio.o)
      _PauseFile in libSDL.a(CDPlayer.o)
  "_SetDSequenceMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_IOServiceGetMatchingServices", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_AudioOutputUnitStart", referenced from:
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _PlayFile in libSDL.a(CDPlayer.o)
  "_IORegistryEntryGetParentEntry", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_KeyTranslate", referenced from:
      _QZ_InitOSKeymap in libSDL.a(SDL_QuartzEvents.o)
      _QZ_InitOSKeymap in libSDL.a(SDL_QuartzEvents.o)
  "_IOObjectRelease", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_AudioUnitSetProperty", referenced from:
      _Core_CloseAudio in libSDL.a(SDL_coreaudio.o)
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _AudioFilePlayer_SetDestination in libSDL.a(AudioFilePlayer.o)
      _AudioFilePlayer_Connect in libSDL.a(AudioFilePlayer.o)
      _AudioFilePlayer_Disconnect in libSDL.a(AudioFilePlayer.o)
  "_DecompressSequenceBeginS", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_IONotificationPortGetRunLoopSource", referenced from:
      _QZ_RegisterForSleepNotifications in libSDL.a(SDL_QuartzEvents.o)
  "_SndNewChannel", referenced from:
      _Mac_OpenAudio in libSDL.a(SDL_romaudio.o)
  "_CGLErrorString", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_EnterMovies", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_ShowMenuBar", referenced from:
      _QZ_UnsetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_SndDoCommand", referenced from:
      _callBackProc in libSDL.a(SDL_romaudio.o)
      _callBackProc in libSDL.a(SDL_romaudio.o)
      _Mac_OpenAudio in libSDL.a(SDL_romaudio.o)
  "_IOServiceMatching", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_glClear", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_AudioUnitInitialize", referenced from:
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _CheckInit in libSDL.a(CDPlayer.o)
  "_ScaleMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_SndDisposeChannel", referenced from:
      _Mac_CloseAudio in libSDL.a(SDL_romaudio.o)
  "_FindCodec", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_CGLSetFullScreen", referenced from:
      _QZ_UnsetVideoMode in libSDL.a(SDL_QuartzVideo.o)
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_IOIteratorNext", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_DecompressSequenceFrameS", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_CDSequenceEnd", referenced from:
      _QZ_FreeHWYUV in libSDL.a(SDL_QuartzYUV.o)
  "_glGetIntegerv", referenced from:
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
  "_IORegistryEntryCreateCFProperties", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [Darwin] Error 1
make: *** [all] Error 2
Re: SDL Makefile help !!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
You should replace libSDL.a* with $(shell sdl-config --libs) in the link line and with $(shell sdl-config --cflags) in the compile line.

shenakan wrote:
I use SDL 1.2 I would like to compile my program with static lib. So what is wrong with my makefile ?
Code:
CC=g++

FLAGS= -Wall -O3

all:
   make -f Makefile `uname`

export
objects: main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o

Darwin:
   make objects 'DEFINES=-DMACOSX'
   $(CC) $(FLAGS) -o evolution  main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

.c.o:
   $(CC) $(DEFINES) $(FLAGS) -c $*.c -I.

.cpp.o:
   $(CXX) $(DEFINES) $(FLAGS) -c $*.cpp -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

clean:
   -rm *.o

CC=g++

FLAGS= -Wall -O3

all:
   make -f Makefile `uname`

export
objects: main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o

Darwin:
   make objects 'DEFINES=-DMACOSX'
   $(CC) $(FLAGS) -o evolution  main.o screen.o screenblock.o draw.o Text.o Operator.o OpInsertText.o OpMoveRect.o OpSwapRect.o SetOperator.o DataImg.o -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

.c.o:
   $(CC) $(DEFINES) $(FLAGS) -c $*.c -I.

.cpp.o:
   $(CXX) $(DEFINES) $(FLAGS) -c $*.cpp -I/usr/local/include/SDL -D_THREAD_SAFE -L. libSDL.a libSDLmain.a -framework Cocoa

clean:
   -rm *.o




Code:

Undefined symbols:
  "_IORegisterForSystemPower", referenced from:
      _QZ_RegisterForSleepNotifications in libSDL.a(SDL_QuartzEvents.o)
  "_ExitMovies", referenced from:
      _QZ_FreeHWYUV in libSDL.a(SDL_QuartzYUV.o)
  "_HideMenuBar", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_IOCreatePlugInInterfaceForService", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_CGLSetParameter", referenced from:
      _QZ_SetupOpenGL in libSDL.a(SDL_QuartzGL.o)
      _QZ_SetupOpenGL in libSDL.a(SDL_QuartzGL.o)
  "_SetIdentityMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_IOMasterPort", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_IOAllowPowerChange", referenced from:
      _QZ_SleepNotificationHandler in libSDL.a(SDL_QuartzEvents.o)
  "_AudioOutputUnitStop", referenced from:
      _Core_CloseAudio in libSDL.a(SDL_coreaudio.o)
      _PauseFile in libSDL.a(CDPlayer.o)
  "_SetDSequenceMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_IOServiceGetMatchingServices", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_AudioOutputUnitStart", referenced from:
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _PlayFile in libSDL.a(CDPlayer.o)
  "_IORegistryEntryGetParentEntry", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_KeyTranslate", referenced from:
      _QZ_InitOSKeymap in libSDL.a(SDL_QuartzEvents.o)
      _QZ_InitOSKeymap in libSDL.a(SDL_QuartzEvents.o)
  "_IOObjectRelease", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_AudioUnitSetProperty", referenced from:
      _Core_CloseAudio in libSDL.a(SDL_coreaudio.o)
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _AudioFilePlayer_SetDestination in libSDL.a(AudioFilePlayer.o)
      _AudioFilePlayer_Connect in libSDL.a(AudioFilePlayer.o)
      _AudioFilePlayer_Disconnect in libSDL.a(AudioFilePlayer.o)
  "_DecompressSequenceBeginS", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_IONotificationPortGetRunLoopSource", referenced from:
      _QZ_RegisterForSleepNotifications in libSDL.a(SDL_QuartzEvents.o)
  "_SndNewChannel", referenced from:
      _Mac_OpenAudio in libSDL.a(SDL_romaudio.o)
  "_CGLErrorString", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_EnterMovies", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_ShowMenuBar", referenced from:
      _QZ_UnsetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_SndDoCommand", referenced from:
      _callBackProc in libSDL.a(SDL_romaudio.o)
      _callBackProc in libSDL.a(SDL_romaudio.o)
      _Mac_OpenAudio in libSDL.a(SDL_romaudio.o)
  "_IOServiceMatching", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_glClear", referenced from:
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_AudioUnitInitialize", referenced from:
      _Core_OpenAudio in libSDL.a(SDL_coreaudio.o)
      _CheckInit in libSDL.a(CDPlayer.o)
  "_ScaleMatrix", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_SndDisposeChannel", referenced from:
      _Mac_CloseAudio in libSDL.a(SDL_romaudio.o)
  "_FindCodec", referenced from:
      _QZ_CreateYUVOverlay in libSDL.a(SDL_QuartzYUV.o)
  "_CGLSetFullScreen", referenced from:
      _QZ_UnsetVideoMode in libSDL.a(SDL_QuartzVideo.o)
      _QZ_SetVideoMode in libSDL.a(SDL_QuartzVideo.o)
  "_IOIteratorNext", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
  "_DecompressSequenceFrameS", referenced from:
      _QZ_DisplayYUV in libSDL.a(SDL_QuartzYUV.o)
  "_CDSequenceEnd", referenced from:
      _QZ_FreeHWYUV in libSDL.a(SDL_QuartzYUV.o)
  "_glGetIntegerv", referenced from:
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
      _QZ_GL_GetAttribute in libSDL.a(SDL_QuartzGL.o)
  "_IORegistryEntryCreateCFProperties", referenced from:
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
      _SDL_SYS_JoystickInit in libSDL.a(SDL_sysjoystick.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [Darwin] Error 1
make: *** [all] Error 2
bazz


Joined: 25 Oct 2010
Posts: 31
It's a sin to post old threads.. I don't care. The real answer to this question is to use
Code:
sdl-config --static-libs