SDL extension libraries on OSX

Started by
7 comments, last by sevensoft 14 years, 2 months ago
Hello, I just started programming with Xcode on Snow Leopard and I've setup SDL.framework and some extra libraries (sdl_image, sdl_mixer, sdl_ttf, sdl_net..) Setting up SDL was indeed easy, just drag the .framework folders to /Library/Frameworks/ and go. I've also installed the documentation for SDL and the templates which comes with it for building an .app bundle. Standard SDL stuff works without any problems, but it's when I wanted to write text onto the screen with sdl_ttf that I ran into problems. It won't compile. I'll show you a screenshot to better explain the error I'm getting. http://img230.imageshack.us/img230/3122/xcode001.png So, I get some sort or reference/symbol error. I'm not very experienced when it comes to error checking, but I'm guessing there's problem with linking. As you can see in the picture I have added sdl_ttf.framework to my project and it should link, also under the target. The include is working fine as long as you tell it to go into that folder first.. I've also looked at the project settings and adding the path there. But I can't seem to get it right. SDL_net (quick test) gives me similar problem when compiling. Please, if you have OSX and Xcode and have sdl_ttf and others working help me out. I really don't know what I'm missing here. Thanks.
Advertisement
I had a similar problem. What does it bring up if you double click on the error?
Only the same info.

Undefined symbols:
"_TTF_Init", referenced from:
Initialize() in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
You have a link error. Since you added the SDL_ttf framework to your project, the most likely cause of the error is that Xcode cannot find the framework.

To fix the error, add the path to the SDL_ttf framework to the Framework Search Paths build setting. In Xcode choose Project > Edit Project Settings. Doing so opens the project's inspector. Click the Build tab in the inspector. The Framework Search Paths build setting is in the Search Paths collection. Double-click the setting in the inspector to add a path. You may also want to add the path to SDL_ttf's header file to the Header Search Paths build setting as well.

If adding the search path does not work, you may want to change the way you include SDL_ttf.h in your code. In the screenshot you posted, you used the following code to include the header:

#include "SDL_TTF/SDL_ttf.h"

You could try changing the include to the following:

#include "SDL_ttf.h"
Mark Szymczyk
Author of Mac Game Programming and Xcode Tools Sensei
http://www.meandmark.com
Tried it, but it gives the same error.
Though, I just checked out the .framework folder and here are the contents.

http://img198.imageshack.us/img198/7205/skrmavbild20091231kl103.png

Compared to the SDL.framework there is nothing in the Resources folder except for the Info.plist.
Is this correct? SDL.framework has SDLMain.nib, but SDL_ttf, _net, _mixer or _image has no .nib file. Only headers.
The following thread from SDL's forum may help you:

http://forums.libsdl.org/viewtopic.php?t=5019&sid=1ba4ce37f083a6618a2ebef2adbbda5c

The thread has the title "SDL_ttf linking error using TTF_GetFontKerning among others" and ran from October 11-20, 2009 if the link doesn't work.
Mark Szymczyk
Author of Mac Game Programming and Xcode Tools Sensei
http://www.meandmark.com
Any luck fixing this? I'm having the exact same problem.. :-/
Quote:Original post by runan
Any luck fixing this? I'm having the exact same problem.. :-/


Nope, sorry. :/
Thought I would drop in and tell you what fixed the issue for me.

Snow Leopard is 64 bit.
Xcode 3.2 defaults everything to intel 64bit.

This bit of info give you the hint:

Ld build/Untitled.build/Debug/Untitled.build/Objects-normal/x86_64/Untitled normal x86_64cd /Users/neeleshsavalani/Documents/Untitledsetenv MACOSX_DEPLOYMENT_TARGET 10.6/Developer/usr/bin/g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/neeleshsavalani/Documents/Untitled/build/Debug -F/Users/neeleshsavalani/Documents/Untitled/build/Debug -F/Users/neeleshsavalani/Library/Frameworks -F/Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks -filelist /Users/neeleshsavalani/Documents/Untitled/build/Untitled.build/Debug/Untitled.build/Objects-normal/x86_64/Untitled.LinkFileList -mmacosx-version-min=10.6 -lSDL_ttf -framework SDL -framework Cocoa -framework SDL_image -framework SDL_ttf -o /Users/neeleshsavalani/Documents/Untitled/build/Untitled.build/Debug/Untitled.build/Objects-normal/x86_64/Untitled 


See that -arch x86_64 is being passed in.
The problem with that is the SDL_ttf does not provide 64bit.

You can validate by running this:


lipo -info /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks/SDL.framework/SDL

Output for SDL itself:
Architectures in the fat file: /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks/SDL.framework/SDL are: x86_64 i386 ppc


Then run it for SDL_ttf:
lipo -info /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks/SDL_ttf.framework/SDL_ttf

Output for SDL_ttf:
Architectures in the fat file: /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks/SDL_ttf.framework/SDL_ttf are: ppc i386

Notice that there is no 64.


So the solution is to go into Xcode > Project > Edit Project Settings > Compiler Version & change the Intel 64-bit to be Intel

Do a clean and build.

This topic is closed to new replies.

Advertisement