Public Group

# [SOLVED] Using SDL in XCode

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

## Recommended Posts

Hi, newbie here. I just started using XCode/C++ a few days ago, and thus don't know too much about it. One of the problems I have at this moment is adding a libary, in my case the SDL (SimpleDirect Media Layer) to my Xcode project. Right now, when I import the SDL framework. However, I get the error:
Quote:
 sdl.h - No such file or directory
How would my code find the SDL.h file in the framework? Sorry again, Im very new to this, so please bear with me. [Edited by - pseudobot on April 21, 2009 12:07:00 AM]

##### Share on other sites
try #include <SDL/SDL.h>

also there might be an issue in the SDLMain file, I can't remember exactly but if you get any more errors just replace 'sdlfilename.h' with <SDL/sdlfilename.h>, all this is assuming you've added SDL.framework to your project

##### Share on other sites
For some reason, it compiles fine now, but I get this error:
Quote:
 sdlapp has exited due to signal 10 (SIGBUS).

The apps code is:
#include <iostream>#include <SDL/SDL.h>using namespace std;int main() {	if (SDL_Init(SDL_INIT_VIDEO) == -1) {		cout << "Could not initalize SDLVideo!";	}		else {		cout << "SDL Initalized!";	}}

##### Share on other sites
have you included SDL_Main? try adding

#include <SDL/SDL_main.h>

also, you will need to put the files SDLMain.m and SDLMain.h to you project, they should be included with your download of SDL

##### Share on other sites
Im still getting the Signal 10 error... :(

##### Share on other sites
hmm that is strange, I would try reinstalling SDL, and trying a new XCode project, are you using the SDL application templates, or starting your project from scratch?

##### Share on other sites
I started the project from scratch. Here is how it looks (in case it might help tracking down the mistake)

##### Share on other sites
well I notice you don't have SDLMain.m in there, this file is actually pretty important because of the way SDL works. What it does is defines it's own main function (which does a lot of setup before you even get to your own main function let alone your call to SDL_Init) it also has a define that looks like this:

#define main SDL_main

this changes your functions name so that your apps real entry point is in SDLMain.m,
I am a little surprised that your compiler isn't complaining about "_main" being undefined

##### Share on other sites
There's only SDL_main.h, no SDLMain.m file in the framework. So, this means I should get the SDL_main.h file out of the framework? Thanks for your help so far btw.

##### Share on other sites
actually, if you download the file under 'development libraries' from the SDL site, there should be a folder inside callde 'SDLMain', in there you want the folder 'NIBless', and there should be SDLMain.m, and SDLMain.h

Quote:
 Original post by pseudobotThanks for your help so far btw.

Glad to help, I remember how much of a headache I had when I tried setting this up for my first time as well :D

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634077
• Total Posts
3015356
×