Xcode 4 with SDL

Started by
3 comments, last by maxfire 11 years, 8 months ago
Hi gys im seeking help from someone who knows about the OSX xcode 4 compiler and runtime

Ok so Im a big fan of SDL and have used it on windows form nearly a year now. After some research I found that the iphone could compile c++ so I have been triyng to get SDL working with xcode 4 on my mac.

after a bit of research I found there is very little help on trying to do this for xcode 4. But from my knowledge from windows it accrued to me that all I really needed to do was add the SDL framework to the project then make the header files visible to the compiler.

This was fairly easy to do a simple test program compiles no problem. Now I hit the hurdle when trying to run the program I get the error message

dyld: Library not loaded: @executable_path/../Frameworks/SDL.framework/Versions/A/SDL

Referenced from: /Users/maxashton/Library/Developer/Xcode/DerivedData/SDL_Test-aolpwbzxuhkmfgategasbecconuo/Build/Products/Debug/SDL_Test.app/Contents/MacOS/SDL_Test

Now from my my knowledge from windows I know that the SDL.dlls have to be in a location which the runtime can see (project folder or system32).

could it be that I am missing the dll equivalent for OSX? if so where could I find these they dont come in the download and the SDL framework isn't something I can compile to create them myself.

Thanks for the help in advanced :)
Advertisement
Yup you're right about it missing the shared library. If you install the runtime libraries for SDL you would see it under your /Libraries/Framework/SDL path (which is roughly equivalent to the DLL being under your system32 folder), or you can embed it inside your application package which is where dyld is telling you it can't find it. You can find the shared library by getting the runtime library here: http://www.libsdl.org/download-1.2.php, although the website is acting a bit strange right now and not giving me actual downloads. If that fails you can build it yourself from the development source on the same page. Just open the XCode project, set the SDK/compiler/OS version appropriately and build the Framework, it'll have what you're missing! Good luck!
@Endogenous
Thanks for the reply, you mentioned installing SDL runtime libraries, on Lion the SDL install and template don't work. I redownloaded the runtime but all I have are header files and one resource .nib file.

Here are my steps so you can see exactly what I did

Manually copy the entire SDL.framework folder from the SDL.dmg download to the /Developer/Library/Frameworks folder.
Created an Xcode koko project removed the current .h and .m files
Included the SDL.Framework in the projects frameworks
Under project Build settings pointed the HeaderSearchPath Bebug and Release to the /Developer/Library/Frameworks/SDL.Framework/headers
Included the SDLMain.h and SDLMain.m files from the devlite folder from the download into the project

Project now successfully compiles but is missing the runtime libs

Copied the SDLmain.nib from SDL.Frameworks/Resources into the project folder Documents/Xcode/Test/Test

Made no difference, maybe this is the wrong place for this?

As I said all of this was guess work from windows knowledge so it is probably something something dead simple

thanks again
Hmm that all seems reasonable, when I download the runtime library and do ls -lR I get:

[source lang="bash"]./SDL.framework:
total 24
lrwxr-xr-x 1 endo staff 24 19 Jan 2012 Headers -> Versions/Current/Headers
lrwxr-xr-x 1 endo staff 26 19 Jan 2012 Resources -> Versions/Current/Resources
lrwxr-xr-x 1 endo staff 20 19 Jan 2012 SDL -> Versions/Current/SDL
drwxr-xr-x 4 endo staff 136 19 Jan 2012 Versions

./SDL.framework/Versions:
total 8
drwxr-xr-x 5 endo staff 170 19 Jan 2012 A
lrwxr-xr-x 1 endo staff 1 19 Jan 2012 Current -> A

./SDL.framework/Versions/A:
total 1464
drwxr-xr-x 40 endo staff 1360 19 Jan 2012 Headers
drwxr-xr-x 4 endo staff 136 19 Jan 2012 Resources
-rwxr-xr-x 1 endo staff 747208 19 Jan 2012 SDL

./SDL.framework/Versions/A/Headers:
total 1216
-rw-r--r-- 1 endo staff 3233 19 Jan 2012 SDL.h
...
-rw-r--r-- 1 endo staff 1482 19 Jan 2012 close_code.h

./SDL.framework/Versions/A/Resources:
total 8
-rw-r--r-- 1 endo staff 1180 19 Jan 2012 Info.plist
drwxr-xr-x 3 endo staff 102 19 Jan 2012 SDLMain.nib

./SDL.framework/Versions/A/Resources/SDLMain.nib:
total 8
-rw-r--r-- 1 endo staff 1701 19 Jan 2012 objects.nib

./devel-lite:
total 40
-rw-r--r-- 1 endo staff 1485 19 Jan 2012 ReadMeDevLite.txt
-rw-r--r-- 1 endo staff 374 19 Jan 2012 SDLMain.h
-rw-r--r-- 1 endo staff 11197 19 Jan 2012 SDLMain.m[/source]
It's the ./SDL.framework/Versions/A/SDL that's 747208 bytes which is the library I think you're looking for. Trying adding that file to the path dyld is looking for. Or just copy the Framework to /Library/Frameworks and hopefully it should work!
ah dude you da man worked like a charm

This topic is closed to new replies.

Advertisement