Results 1 to 6 of 6

Thread: JEDI-SDL and Snow Leopard

  1. #1

    JEDI-SDL and Snow Leopard

    Did anyone have any success getting a working development environment with SDL on Mac OS Snow Leopard?
    The applications I compiled with Leopard work on Snow Leopard, but there some issues when compiling my projects in Snow Leopard.

    There is an issue with SDLmain and doesn't work with the Snow Leopard SDK, so you need to add the following when compiling:
    Code:
    -XR/Developer/SDKs/MacOSX10.5u.sdk/ -k-macosx_version_min -k10.5
    (The Tiger SDK is broken at the moment, I hope 10.6.2 or a new XCode version will fix that problem.)

    But then I get a strange linking error that the frameworks (Cocoa and the SDL frameworks) could not be found. Can anyone help me or point me in the right direction?
    The Cocoa framework is installed in /System/Library/Framework, the SDL frameworks in /Library/Frameworks

    I also tried the latest FreePascal 2.5.1 (daily snapshot), same linking error there.
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

  2. #2

    Re: JEDI-SDL and Snow Leopard

    I found a solution.
    It is a small workaround for now until SDL 1.2.14 will be released.

    A few steps to get SDL applications working on Snow Leopard:
    1. Checkout the latest SDL SVN source and compile the framework for yourself with XCode.
    Alternatively: I also uploaded the framework to my webspace. Download it here.
    2. Copy the framework to /Library/Frameworks
    3. Extract libSDLmain.a as described here: http://wiki.lazarus.freepascal.org/F...mework_version
    4. Add the following lines to your code:
    Code:
    {$linklib SDLmain}
    {$PASCALMAINNAME SDL_main}
    5. Compile your source code and don't forget to link against the frameworks (at least Cocoa and SDL)

    Note: The compiled just works on Snow Leopard. Building with 10.5 SDK does not work (at least not at the moment).

    Building with Tiger SDK works, if you slightly change step 3. Add "-fno-stack-protection" (without ") to your compiler flags.

    There are still some problems with SDL_gfx though, like wrong color when drawing primitives.
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: JEDI-SDL and Snow Leopard

    Hey Stoney, I'm just now starting to learn how to install SDL for the Mac. It seems that your small tutorial here is all that we have here at PGD.

    You seem to have simplified a few things (big thanks!) however there is something left out it seems. Where you tell us that we have to compile the SDL.framework files to make our static library, you've left out the details that the FPC article alludes to. I downloaded your copy of the SDL.framework, thanks for making that easy. But I'm stuck at where 'devel-lite' is mentioned in the article, but you have not given any details on this. Is this needed? And if so where is this Mac OS X version they are talking about? If you don't download a Windows version, you only get source. Also when I run the following code...

    Code:
    gcc -c -o SDLMain.o SDLMain.m -I /Library/Frameworks/SDL.framework/Headers
    ar r libSDLMain.a SDLMain.o
    ranlib libSDLMain.a
    ...it complains that SDLMain.o and SDLMain.m cannot be found. Where are these files? And what should I be doing about the apparently missing files?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: JEDI-SDL and Snow Leopard

    Ok I'm a dummy! I just looked over the libsdl.org site again and wouldn't you know it, I found the proper Mac OS X download and inside the proper dmg file was the devel-lite folder in question.

    I cracked open Terminal and went to the devel-lite folder as the link mentions and ran the gcc compiler and linker with the told commands and viola the SDLMain.a file is now created.

    Now... whats all this about linking toward Cocoa? And where is the best place to put SDLMain.a? I figure in the same main folder as my project in question, no? I'm using the latest version of Lazarus for Mac OS X (that's v0.9.28.2 beta as of this post) would Lazarus not have this taken care of for me?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: JEDI-SDL and Snow Leopard

    Ok well continuing on as best I can, it seems that the Cocoa issue isn't that big of a deal, I'm currently linking with carbon (beta) as thats seems to be satisfying it. I do have another issue already. I use sdl_mixer and glext in my projects and they seem to be having issues.

    Here is the top of my program...

    Code:
    program arcade;
    
    { =================================== }
    { ======   ARCADE CLONE   ====== }
    { =================================== }
    { Programmed by Jason "WILL" McMillen }
    { =================================== }
    { Copyright 2010 Red Ant Productions }
    { =================================== }
    
    {$IFDEF Win32}
     {$IFDEF FPC}
      {$APPTYPE GUI}   // FreePascal/Lazarus
     {$ELSE}
      {$APPTYPE CONSOLE} // Delphi
     {$ENDIF}
    {$ENDIF}
    {$IFDEF DARWIN}
     {$IFDEF FPC}
      {$linklib SDLmain}
      {$PASCALMAINNAME SDL_main}
      {$APPTYPE GUI}   // FreePascal/Lazarus
     {$ENDIF}
    {$ENDIF}
    //{$mode objfpc}{$H+}
    
    uses
     SysUtils,
     // JEDI-SDL
     sdl,
     sdl_mixer,
     // OpenGL
     gl,
     glu,
     glext,
     // Game Engine
     InputUnit,
     GraphicsUnit,
     FontUnit,
     GameObjectUnit,
     GameConstantsUnit,
     GUIUnit;
    And these are my errors...

    arcade.lpr(22,6) Note: APPTYPE is not supported by the target OS
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/SDL/Pas/jedi-sdl.inc(232,4) Warning: Illegal compiler directive "$THREADING"
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3767,27) Hint: Conversion between ordinals and pointers is not portable
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3767,19) Hint: Conversion between ordinals and pointers is not portable
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3768,34) Hint: Conversion between ordinals and pointers is not portable
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3768,2 Hint: Conversion between ordinals and pointers is not portable
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3767,27) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3768,34) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3888,3) Note: Local variable "extstring" is assigned but never used
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3168,10) Error: Forward declaration not solved "Load_WGL_NV_render_texture_rectangle:Boolean; "
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(3234,10) Error: Forward declaration not solved "Load_WGL_ATI_pixel_format_float:Boolean;"
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(60,15) Hint: Unit "moduleloader" not used in glext
    /Users/jasonmcmillen/Documents/Pascal Projects/JEDI-SDLv1.0/OpenGL/Pas/glext.pas(852 Fatal: There were 2 errors compiling module, stopping
    And in case you're wondering, yes I put in absolute paths into my 'Compiler Options...' fields for both Units and Includes.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6

    Re: JEDI-SDL and Snow Leopard

    SDL 1.2.14 has already been released a few months back, so you can go ahead and use the SDL.framework from libsdl.org, my SDL.framework-file is a bit older than the official file.

    Placing libSDLmain.a in the project folder is a good way. Alternatively you can place libSDLmain.a in the folder you want and then use -Flpath/to/my/folder (Compiler Options | Paths | Libraries in Lazarus).
    This whole libSDLmain.a - stuff will become unnecessary in SDL 1.3.

    Linking against frameworks can be done in three different ways:
    1. In your code:
    Add
    Code:
    {$linkframework MyFramework}
    some where at the top of your code (usually directly after the program or unit line). Don't forget IFDEFs if you want to compile the code on other platforms as well.
    Or:
    2. Command-Line:
    If you compile the project via commandline. Add
    Code:
    -k-framework -kMyFramework
    Or:
    3. In Lazarus:
    Go To Compiler Options | Linking | Options. Check the field "Pass Options To Linker..." and add in the box:
    Code:
    -framework MyFramework
    Parts of SDL are built upon Cocoa, the standard Mac OS library since Mac OS X. Cocoa handles something like windows, input etc. Think of it as Mac OS X's WinAPI.

    Also you need to link against /usr/X11R6/lib. I don't really know why, because linking against X11 does absolutely nothing. (The end-user does not have to install X11 on their machine when starting your application.) But for now it has to be that way.

    So if you chose Option 3 for linking the frameworks, your Linking-Options-box would look like this:
    Code:
    -framework Cocoa -framework SDL -L/usr/X11R6/lib

    Edit: Just saw your new post: Try to use the OpenGL-libraries provided by FreePascal instead of the OpenGL libraries by JEDI-SDL.
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

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
  •