• Advertisement
Sign in to follow this  

SDL, eclipse & MacOS X

This topic is 3485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, currently I'm trying to compile a simple SDL sample with eclipse on a Mac (OS X Leopard). I followed the guide on http://meandmarkpublishing.blogspot.com/2006/12/setting-up-sdl-for-eclipse-on-mac-os-x.html to the best of my knowledge. I'm a Mac noob still so I can't be sure, I missunderstood something. I'm getting errors about the sdl/sdl.h not being where it is supposed to be, though I added the include path for the framework. make all Building file: ../src/SDL_OpenGL_test.cpp Invoking: GCC C++ Compiler g++ -I/Network/Servers/coleman.informatik.RWTH-Aachen.DE/Volumes/RAID2/Hiwis/kurtz/Library/Frameworks/SDL.framework/Versions/A/Headers -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SDL_OpenGL_test.d" -MT"src/SDL_OpenGL_test.d" -o"src/SDL_OpenGL_test.o" "../src/SDL_OpenGL_test.cpp" Finished building: ../src/SDL_OpenGL_test.cpp Building target: SDL_OpenGL_test Invoking: MacOS X C++ Linker g++ -framework Cocoa -framework SDL /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m -o "SDL_OpenGL_test" ./src/SDL_OpenGL_test.o /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:8:21: error: SDL/SDL.h: No such file or directory /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m: In function '-[SDLApplication terminate:]': /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:75: error: 'SDL_Event' undeclared (first use in this function) /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:75: error: (Each undeclared identifier is reported only once /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:75: error: for each function it appears in.) /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:75: error: syntax error before 'event' /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:76: error: 'event' undeclared (first use in this function) /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:76: error: 'SDL_QUIT' undeclared (first use in this function) make: *** [SDL_OpenGL_test] Error 1 Thx for any ideas that might come up.

Share this post


Link to post
Share on other sites
Advertisement
If it's building ok then you are including all the right stuff..

It appears to be failing at the linking stage..

Assuming you are using XCode then what you need to do is make sure that there is 'Link Binary With Libraries' section in your target project. Target is the red bulls-eye part way down the left panel in XCode. Your target project will be in there.

If there isn't a 'Link Binary with Libraries' in it, make one. But there really should be one there!

Then drag the SDL framework icon into it.

Let me know if you still have problems after that..

EDIT - Re-reading your post I realize you are using Eclipse, which I am not familiar with. But basically the problem remains the same.. You need to setup linking for the framework.

Share this post


Link to post
Share on other sites
Thx for the quick response! I'm working with an eclipse project. So I can't do what you asked for. The sample compiles fine with XCode btw. I'm trying to use eclipse though because I want the project to be portable to my windows PC :-)

Share this post


Link to post
Share on other sites
In Eclipse use the following settings:

GCC C++ compiler
-Directories : "/System/Library/Frameworks/SDL.framework/Versions/A/Headers"

// assuming SDL is installed in /System/Library

Then use the following settings under the Mac OSX C++ Linker tab

- Miscellanous - Linker flags : -framework SDL -framework Cocoa
~*ABSOLUTE PATH TO YOUR* SDLMain.m

Share this post


Link to post
Share on other sites
I thought, that's what i have done:

g++ -I/Network/Servers/coleman.informatik.RWTH-Aachen.DE/Volumes/RAID2/Hiwis/kurtz/Library/Frameworks/SDL.framework/Versions/A/Headers -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SDL_OpenGL_test.d" -MT"src/SDL_OpenGL_test.d" -o"src/SDL_OpenGL_test.o" "../src/SDL_OpenGL_test.cpp"

(I know, the line is bit lenghty, but it the framework is set as include path)

and

g++ -framework Cocoa -framework SDL /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m -o "SDL_OpenGL_test" ./src/SDL_OpenGL_test.o

All the files are where they are supposed to be (if I'm not missing anything because I'm unaware of Mac specifics)

Share this post


Link to post
Share on other sites
What does the include / import statement look like in SDLMain.m?

/Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m:8:21: error: SDL/SDL.h: No such file or directory

Share this post


Link to post
Share on other sites
Edit: IGNORE THAT!

Thx again, I found out, that the '~' is not part of the '*absolute path to your*' placeholder. Now I only get one error left:

g++ -framework Cocoa -framework SDL ~/Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m -o "SDL_OpenGL_test" ./src/SDL_OpenGL_test.o
i686-apple-darwin9-g++-4.0.1: /Network/Servers/coleman.informatik.RWTH-Aachen.DE/Volumes/RAID2/Hiwis/kurtz/Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m: No such file or directory
make: *** [SDL_OpenGL_test] Error 1

Edit: IGNORE THAT!

Share this post


Link to post
Share on other sites
Paths can be funny things on the Mac:

~ is actually your Home folder. So you now are not getting to SDLMain.m

/Users... should be ok.

You could also use

/Volumes/<your sys volume>/Users/..

I am thinking that the SDL/SDL.h needs to be changed in SDLMain.m to point to the header files properly (for your implementation).

In XCode #include or #import <SDL/SDL.h> directs it to look inside a framework with the first half of the filename being the frameworks name..

A Quick and Dirty solution is to change that to an absolute path, or an include path within your project and make a copy of SDL.h there.

Share this post


Link to post
Share on other sites
Thx again, but has not changed anything :-( (sure bout changing the include to SDLMain.m? Isn't that a circle reference?)

Could it be, that for some weird reason eclipse may not access the Framework-Folder while XCode can (it's located on a server)?

Share this post


Link to post
Share on other sites
I think you misunderstand me...

Try changing the line to..

#import "/Network/Servers/coleman.informatik.RWTH-Aachen.DE/Volumes/RAID2/Hiwis/kurtz/Library/Frameworks/SDL.framework/Versions/A/Headers/SDL.h"

or..

#include "/Network/Servers/coleman.informatik.RWTH-Aachen.DE/Volumes/RAID2/Hiwis/kurtz/Library/Frameworks/SDL.framework/Versions/A/Headers/SDL.h"

Let me know if that works... It's not a neat solution, but will give us some info.

If it does then you have a couple of options. One is to keep a copy of SDL.h in your project and then you can just do an include "SDL.h".

Share this post


Link to post
Share on other sites
Thx again, sorry I really messed that up. In fact there is a new and informative error message now:

make all
Building target: SDL_OpenGL_test
Invoking: MacOS X C++ Linker
g++ -framework Cocoa -framework SDL /Users/Shared/Cpp_workspace/SDL_OpenGL_test/src/SDLMain.m -o "SDL_OpenGL_test" ./src/SDL_OpenGL_test.o
ld: framework not found SDL
collect2: ld returned 1 exit status
make: *** [SDL_OpenGL_test] Error 1

I don't have full admin permissions here, so I put the framework into my home directory.

Share this post


Link to post
Share on other sites
Try putting the framework into your Framework directory.
If you do that then it should find it in that location as it's part of the default path.

If you want to keep it in your home directory you'll have to make that a valid search path for the linker to look into for stuff.

Make sense?

In other words a quick and dirty solution to make this work on your machine, is to put it into /Volumes/System/Library/Frameworks/

Then all apps will be able to load it on your machine at run time, and the linker should link with it as long as you include the framework with -framework as you are now.

A better solution is to put it inside your program's app bundle, but let's leave that for now to get you working.

I am not sure of your setup...
But, if you don't have permission to put into /Volumes/System/Library/Frameworks/ you can also put it into your Users Framework folder. This should be in ~/Library/
If it's not then make a Framework folder and put it in that.

Bottom line is that the Compiler, Linker and your program at runtime all need to know where to get the Framework from. :)

Share this post


Link to post
Share on other sites
The framework resides at "~/Library/Frameworks/SDL.framework" already. That was what I did in the first place. I also added that as Include path for the compiler (not for the linker as I was told, that one cant use -framework together with -l).

Share this post


Link to post
Share on other sites
I must be missing something that I take for granted in XCode.

My gut feeling is that the linker has not had all it's search paths defined correctly.
I am assuming that ~/Library/Frameworks is a default search path for Frameworks.
It is certainly one place where apps look to load Frameworks from at launch.
Perhaps it's not being setup at build time, so try to set the header and framework paths in the command line and see if that helps...

I'll do some digging and if I have a brain wave I'll post back here.

Share this post


Link to post
Share on other sites
Thx for the troubles, but I think I'll go with XCode and Objective C then. Wont hurt me that much to wrap my head around that Apple way of doing things. Thx again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement