Jump to content
  • Advertisement
Sign in to follow this  
pseudobot

[SOLVED] Using SDL in XCode

This topic is 3319 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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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!";
}
}


Please help.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
I started the project from scratch. Here is how it looks (in case it might help tracking down the mistake)
(Please excuse the size)
SDL project

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 pseudobot
Thanks 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

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!