Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 37

Thread: Linking Issues on MacOS X 10.6.5

  1. #21
    Yep. This is the 2nd variant I mentioned (ports). Fink is another approach (but currently not working on Snow Leopard). Both work like apt-get. Hmmm... perhaps they also have a FreePascal port ... if this would be the case, I could use the Ports or Fink version of SDL and FPC.

    If that worked, I only fear that the end users would need to install Ports, too ... or at least X11. I don't know if the casual Mac user, who would perhaps play my roguelike game, would do this.

    However, I'll check this idea out.


    Edit: Ok, there's no Ports version of FPC *sigh*
    Last edited by Mario Donick; 08-01-2011 at 12:22 PM.

  2. #22
    Some sdl wiki page mentioned that you needed to use Projectbuilder to build sdl properly(as frameworks). Did you do that?

    And when you used frameworks+the unix way what was the problem then, precisely?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #23
    No -- I simply did ./configure, make, make install, as mentioned in the MacOS readme of the SDL source. Also the FPC wiki says that you don't need to use the Framework, you CAN use the Unix way.

    The generated libraries were stored in the right place, with the right names, but the linker complained that they were built for a wrong platform (although I explicitly told the configure script to build for i386 Intel Macs, not for PowerPC Macs).

  4. #24
    And are you on an i386 or a x86_64?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  5. #25
    The Mac Mini has an Intel Core Duo 2 (= i386).

    At the moment, I'm considering simply wrapping the Windows version of the game with WineBottler to produce the Mac version. I tried this, this works, but a whole Wine environment would be included then. Not the best way.

  6. #26
    Core Duo 2 can run both i386 and x86_64. I thought OSX usually ran as x86_64?

    Try to compile your program as fpc -Px86_64 fprl

    Edit: Nevermind that. I was wrong...
    Last edited by JSoftware; 08-01-2011 at 08:00 PM.
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  7. #27
    Never mind. I appreciate all guesses

    I have again played around with bundling the game plus Wine. It looks good. One single .app that can safely reside in MacOS' app folder. It's as fast as on Windows, everything works very good (okay, that's because its a simple 2D game which is handled well by Wine).

    However, its size is around 420 MB, and from this, the game is only 200 MB. I'll see if I can host this somewhere.

  8. #28
    Quote Originally Posted by Mario Donick View Post
    Also the FPC wiki says that you don't need to use the Framework, you CAN use the Unix way.
    This is not recommended. The end-user would need to install libSDL*.dylib and all SDL friends on their computer. The framework way is much better for deployment.

    I wouldn't bundle it with WineBottler, native applications are always faster than applications running through Wine.

    If you use "fpc -Mobjfpc -ve -k-lSDLmain -k-framework -kSDL -k-framework -kSDL_image -k-framework -kCocoa -Fl/usr/X11/lib fprl.pp" and the JEDI-SDL headers everything should work fine.

    Alternatively, you can add
    {$IFDEF DARWIN}
    {$PASCALMAINNAME SDL_main} // Needed for Snow Leopard
    {$linklib SDLmain}

    {$linkframework Cocoa}
    {$linkframework SDL}
    {$linkframework OpenGL}

    {$linkframework SDL_image}
    {$linkframework SDL_mixer} // If you are using SDL_mixer
    {$IFDEF USE_SDL_GFX} // If you are using SDL_gfx
    {$linkframework SDL_net} // If you are using SDL_net
    {$ENDIF}
    at the top of your main source file and compile your application with: fpc -Mobjfpc -ve -Fl/usr/X11/lib fprl.pp

    Btw: If you are still interested in Universal binaries, this is my Mac and Linux compile script which compiles an universal binary, copies all my assets and creates a nice .app file around the application. I've been using this in all my Mac FreePascal SDL game projects.
    #!/bin/sh

    FPC_BIN=`which fpc`
    BIN_FOLDER="../bin"
    SRC_MAIN="main.lpr"
    LIB_FOLDER="../lib"
    EXEC_NAME="execname"
    APP_NAME="My Application Name"


    cd ../source
    if [ -f /System/Library/Frameworks/Cocoa.framework/Cocoa ]
    then

    FPC_BIN=`which ppc386`

    # Compiling Intel binary
    ${FPC_BIN} @config.cfg -k-L/usr/X11R6/lib ${SRC_MAIN}
    mv ${BIN_FOLDER}/main ${BIN_FOLDER}/main-intel
    rm ${BIN_FOLDER}/link.res
    rm ${BIN_FOLDER}/*.o ${BIN_FOLDER}/*.ppu
    rm ${SRC_HEADER}/*.o ${SRC_HEADER}/*.ppu ${SRC_HEADER}/*.dcu ${SRC_HEADER}/*.a


    FPC_BIN=`which ppcppc`

    # Compiling PowerPC binary
    ${FPC_BIN} @config.cfg -k"-L${LIB_FOLDER}/frameworks -L/usr/X11R6/lib" ${SRC_MAIN} -XR/Developer/SDKs/MacOSX10.5.sdk/ -k-macosx_version_min -k10.5
    mv ${BIN_FOLDER}/main ${BIN_FOLDER}/main-ppc
    rm ${BIN_FOLDER}/*.o ${BIN_FOLDER}/*.ppu


    # Creating universal binary
    if [ -f ${BIN_FOLDER}/main-intel ] && [ -f ${BIN_FOLDER}/main-ppc ]
    then
    strip ${BIN_FOLDER}/main-intel
    strip ${BIN_FOLDER}/main-ppc

    lipo -create ${BIN_FOLDER}/main-intel ${BIN_FOLDER}/main-ppc -output ${BIN_FOLDER}/${EXEC_NAME}
    rm -rf ${BIN_FOLDER}/main-intel
    rm -rf ${BIN_FOLDER}/main-ppc
    fi

    if [ -d "${BIN_FOLDER}/${APP_NAME}.app" ]
    then
    echo " ... Removing old application"
    rm -rf "${BIN_FOLDER}/${APP_NAME}.app"
    fi

    echo " ... Creating Application Bundle"

    mkdir "${BIN_FOLDER}/${APP_NAME}.app"
    mkdir "${BIN_FOLDER}/${APP_NAME}.app/Contents"
    mkdir "${BIN_FOLDER}/${APP_NAME}.app/Contents/MacOS"
    mkdir "${BIN_FOLDER}/${APP_NAME}.app/Contents/Resources"
    mkdir "${BIN_FOLDER}/${APP_NAME}.app/Contents/Frameworks"

    cp -R ../resources/ "${BIN_FOLDER}/${APP_NAME}.app/Contents/Resources/"

    # Copy frameworks from System
    cp -R /Library/Frameworks/SDL.framework "${BIN_FOLDER}/${APP_NAME}.app/Contents/Frameworks/"
    cp -R /Library/Frameworks/SDL_mixer.framework "${BIN_FOLDER}/${APP_NAME}.app/Contents/Frameworks/"
    cp -R /Library/Frameworks/SDL_ttf.framework "${BIN_FOLDER}/${APP_NAME}.app/Contents/Frameworks/"

    mv "${BIN_FOLDER}/${EXEC_NAME}" "${BIN_FOLDER}/${APP_NAME}.app/Contents/MacOS/"

    echo "<?xml version='1.0' encoding='UTF-8'?>\
    <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\
    <plist version=\"1.0\">\
    <dict>\
    <key>CFBundleDevelopmentRegion</key>\
    <string>English</string>\
    <key>CFBundleExecutable</key>\
    <string>${EXEC_NAME}</string>\
    <key>CFBundleIconFile</key>\
    <string>logo.icns</string>\
    <key>CFBundleIdentifier</key>\
    <string>com.freezedev</string>\
    <key>CFBundleInfoDictionaryVersion</key>\
    <string>6.0</string>\
    <key>CFBundleName</key>\
    <string>${APP_NAME}</string>\
    <key>CFBundlePackageType</key>\
    <string>APPL</string>\
    <key>CFBundleSignature</key>\
    <string>PSGR</string>\
    <key>CFBundleVersion</key>\
    <string>1.0</string>\
    <key>CSResourcesFileMapped</key>\
    <true/>\
    </dict>\
    </plist>" >> "${BIN_FOLDER}/${APP_NAME}.app/Contents/Info.plist"

    echo "APPLFDRS" >> "${BIN_FOLDER}/${APP_NAME}.app/Contents/PkgInfo"

    else
    if [ -f /usr/lib64 ]
    then
    ${FPC_BIN} @config.cfg ${SRC_MAIN}
    rm ${BIN_FOLDER}/*.o ${BIN_FOLDER}/*.ppu
    else
    ${FPC_BIN} @config.cfg ${SRC_MAIN}
    rm ${BIN_FOLDER}/*.o ${BIN_FOLDER}/*.ppu
    fi

    if [ -f "${BIN_FOLDER}/main" ]
    then
    mv "${BIN_FOLDER}/main" "${BIN_FOLDER}/${EXEC_NAME}"
    fi
    fi
    If you want to use this for your projects, you need to change the variables at the top (BIN_FOLDER, SRC_MAIN, LIB_FOLDER, EXEC_NAME and APP_NAME) to the value you want them to be. You need to delete the reference to config.cfg if you are not using a config file for your project and libSDLmain.a should be in LIB_FOLDER/frameworks for PowerPC compilation.
    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.

  9. #29
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    oooh, shiny. i must say; i do appreciate bash scripts a lot. now where can i use this seeing i dont have mac? hmm. tough one
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  10. #30
    @Stoney, thank you! This looks like a great solution, I'll try this now and report back soon.

    Edit:

    I added the IFDEFs at the beginning of my main file. Here the results:


    1. When I use the single compiler call you gave me above, with the JEDI SDL headers (not the ones included in FPC), the game compiles and links, but crashes as soon as it tries to call SDL_INIT.

    2. When I use your build script, it tells me:

    Code:
    Linking fprl
    ld: warning: in ./libSDLmain.a, file was built for unsupported file format which is not the architecture being linked (i386)
    Undefined symbols:
      "_main", referenced from:
          __start in crt1.o
         (maybe you meant: _SDL_main)
    So nothing has changed.

    The libSDLmain file was created by me some days ago using the "devel-lite" folder in the SDL for Mac download, and using the following compiler call (as stated in the FreePascal wiki):

    Code:
    gcc -c -o SDLMain.o SDLMain.m -I /Library/Frameworks/SDL.framework/Headers
    ar r libSDLMain.a SDLMain.o
    ranlib libSDLMain.a
    But somehow the resulting library seems not to be correct.
    Last edited by Mario Donick; 09-01-2011 at 09:30 AM.

Page 3 of 4 FirstFirst 1234 LastLast

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
  •