Results 1 to 6 of 6

Thread: Xcode SDL2 issue: "Undefined symbols for architecture i386"

  1. #1

    Xcode SDL2 issue: "Undefined symbols for architecture i386"

    I've got FreePascal and Xcode 4.2 installed on a virtual Mac OS X 10.6.7 machine. I've also got the SDL2, SDL2_image and SDL2_mixer frameworks installed and my source files include sdl2.pas, sdl2_image.pas and sdl2_mixer.pas as well as jedi.inc and all sdl inc files. When I try to build my project in Xcode, I get the following errors:


    Undefined symbols for architecture i386:
    "_Mix_Pause", referenced from:
    _TOOLBOX_PAUSEGAME in toolbox.o
    "_SDL_GL_SwapWindow", referenced from:
    _SCREEN_UPDATESCREEN in screen.o
    "_Mix_LoadMUS", referenced from:
    _MUSIC_LOADANDPLAYMUSIC$PCHAR in music.o
    "_SDL_GL_CreateContext", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_Mix_Resume", referenced from:
    _TOOLBOX_PAUSEGAME in toolbox.o
    "_IMG_Load", referenced from:
    _TOOLBOX_LOADSCREEN$BOOLEAN in toolbox.o
    "_Mix_PlayMusic", referenced from:
    _MUSIC_LOADANDPLAYMUSIC$PCHAR in music.o
    "_Mix_VolumeMusic", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    _TOOLBOX_PAUSEGAME in toolbox.o
    _OPTIONS_OPTIONSMENU in options.o
    "_SDL_GL_SetAttribute", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_ShowCursor", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_GL_DeleteContext", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_Mix_FreeMusic", referenced from:
    _GAMELOOP_RUNGAME in gameloop.o
    _MUSIC_LOADANDPLAYMUSIC$PCHAR in music.o
    _QUINE_USENEWQUINE in quine.o
    "_Mix_Playing", referenced from:
    _SOUNDS_PLAYSOUND$BYTE$BYTE in sounds.o
    _SOUNDS_NOAFTERBURNERSOUND in sounds.o
    _SOUNDS_NOSTATICSOUND in sounds.o
    "_SDL_InitSubSystem", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_Mix_HaltMusic", referenced from:
    _GAMELOOP_RUNGAME in gameloop.o
    _MUSIC_LOADANDPLAYMUSIC$PCHAR in music.o
    "_SDL_RWFromFile", referenced from:
    _SDL2_SDL_LOADBMP$PCHAR$$PSDL_SURFACE in sdl2.o
    _SDL2_MIXER_MIX_LOADWAV$PCHAR$$PMIX_CHUNK in sdl2_mixer.o
    "_SDL_FreeSurface", referenced from:
    _TOOLBOX_LOADSCREEN$BOOLEAN in toolbox.o
    "_Mix_OpenAudio", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_SetWindowPosition", referenced from:
    _OPTIONS_OPTIONSMENU in options.o
    "_SDL_PollEvent", referenced from:
    _INPUT_GETKEYS in input.o
    "_Mix_AllocateChannels", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_SetWindowFullscreen", referenced from:
    _OPTIONS_OPTIONSMENU in options.o
    "_IMG_Quit", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_SDL_DestroyWindow", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_Mix_HaltChannel", referenced from:
    _GAMELOOP_RUNGAME in gameloop.o
    _SOUNDS_NOAFTERBURNERSOUND in sounds.o
    _SOUNDS_NOSTATICSOUND in sounds.o
    _QUINE_USENEWQUINE in quine.o
    "_SDL_SetWindowSize", referenced from:
    _OPTIONS_OPTIONSMENU in options.o
    "_SDL_Delay", referenced from:
    _INPUT_ANSWERYES$BOOLEAN$$BOOLEAN in input.o
    _TOOLBOX_MYDELAY$LONGINT in toolbox.o
    "_Mix_LoadWAV_RW", referenced from:
    _SDL2_MIXER_MIX_LOADWAV$PCHAR$$PMIX_CHUNK in sdl2_mixer.o
    "_SDL_Init", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_Mix_ReserveChannels", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_GetCurrentDisplayMode", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_PumpEvents", referenced from:
    _INPUT_PUMPEVENTS in input.o
    _TOOLBOX_CIRCULARWIPEIN$BYTE$BYTE in toolbox.o
    _TOOLBOX_CIRCULARWIPEOUT$BYTE$BYTE in toolbox.o
    "_Mix_Volume", referenced from:
    _SOUNDS_PLAYSOUND$BYTE$BYTE in sounds.o
    "_SDL_LoadBMP_RW", referenced from:
    _SDL2_SDL_LOADBMP$PCHAR$$PSDL_SURFACE in sdl2.o
    "_SDL_Quit", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSTART in toolbox.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_SDL_GetMouseState", referenced from:
    _TOOLBOX_GETMOUSECOORDINATES in toolbox.o
    "_SDL_WarpMouseInWindow", referenced from:
    _INPUT_MOVEMOUSEWITHKEYBOARD$BOOLEAN in input.o
    _INPUT_SETMOUSEPOSITION$BYTE$BYTE in input.o
    _TOOLBOX_GETMOUSECOORDINATES in toolbox.o
    "_Mix_PlayChannelTimed", referenced from:
    _SDL2_MIXER_MIX_PLAYCHANNEL$LONGINT$PMIX_CHUNK$LON GINT$$LONGINT in sdl2_mixer.o
    "_Mix_Quit", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_Mix_PlayingMusic", referenced from:
    _GAMELOOP_RUNGAME in gameloop.o
    _MUSIC_LOADANDPLAYMUSIC$PCHAR in music.o
    _MUSIC_PLAYSPACEMUSIC in music.o
    _MUSIC_PLAYBASEMUSIC in music.o
    "_Mix_FreeChunk", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_SDL_GetTicks", referenced from:
    _P$ASCIISEC_STARTGAME in asciisec.o
    _MOVIES_PLAYMOVIE$ANSISTRING in movies.o
    _TOOLBOX_DODELAY$LONGINT in toolbox.o
    _SPACE_FLYINSPACE in space.o
    _ONBASE_ONABASE in onbase.o
    _MAINU2_NAVCOMPUTER in mainu2.o
    _MAINU4_HANDLEKEYS in mainu4.o
    ...
    "_Mix_CloseAudio", referenced from:
    _INPUT_GAMEWINDOWCLOSED in input.o
    _TOOLBOX_PROGRAMSHUTDOWN in toolbox.o
    "_SDL_CreateWindow", referenced from:
    _TOOLBOX_PROGRAMSTART in toolbox.o
    "_SDL_SetWindowIcon", referenced from:
    _TOOLBOX_LOADSCREEN$BOOLEAN in toolbox.o
    ld: symbol(s) not found for architecture i386
    An error occurred while linking
    asciisec.pas(634,19) Error: Error while linking
    asciisec.pas(634,19) Fatal: There were 1 errors compiling module, stopping
    Fatal: Compilation aborted


    It pretty much seems like it isn't finding any sdl2 libraries/frameworks, but I can't for the life of me figure out what I'm doing wrong?
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  2. #2
    1. Which SDL2 headers are you using?
    2. Sure you got all the development libs? (And for the right arch?)

  3. #3
    I'm using these headers:

    https://github.com/ev1313/Pascal-SDL-2-Headers

    And have installed the Mac OS X SDL 2 frameworks from the official sources (I mean, I didn't install them from source files, I downloaded the .dmg's from the official websites and installed them by copying the frameworks into the Library/Frameworks/ folder). There's only one .dmg to choose for SDL2, SDL2_image and SDL2_mixer, respectively.

    I'm also using the Xcode 4 Objective Pascal templates from here:

    https://dl.dropboxusercontent.com/u/...bjP/index.html

    I'm fairly sure that it's an issue with Xcode not finding the SDL 2 libraries/frameworks during linking, but I don't know how to fix that. I've tried setting the framework path in Build Settings, but that didn't help.
    Last edited by Christian Knudsen; 09-02-2015 at 12:10 PM.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  4. #4
    Finally some progress!

    I had to add:

    {$IFDEF DARWIN}
    {$linkframework Cocoa}
    {$linkframework SDL2}
    {$linkframework OpenGL}
    {$linkframework SDL2_image}
    {$linkframework SDL2_mixer}
    {$ENDIF}

    To the main source file to get it to compile. I have no idea why, though. It now crashes when setting up the OpenGL context during runtime, but at least it's compiling now!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  5. #5
    ev1313's headers use {$LINKLIB} to specify linking to SDL2. I'm guessing that because you put the SDL2 lib in Frameworks/, {$LINKLIB} failed to find them so you had to use {$LINKFRAMEWORK}.

  6. #6
    Ahhh, that makes sense! There should probably be a notice about that in a readme or somewhere else, since per the installation instructions on the SDL2 website, most people will probably install the frameworks in Library/Frameworks.

    I also fixed the OpenGL crashing issue (I had OpenGL was set to PROFILE_CORE when it should be PROFILE_COMPATIBITY as I'm using immediate mode). I've never been this relieved to just manage to compile and run some code before!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL