Jump to content

  • Log In with Google      Sign In   
  • Create Account


szymczyk

Member Since 15 Jan 2000
Offline Last Active Oct 01 2013 12:15 PM

#4930042 Having loads of trouble compiling C++ SDL/OpenGL project on Mac OS X

Posted by szymczyk on 10 April 2012 - 06:08 PM

EDIT: On clean and rebuild I've discovered SDLMain is throwing up a ton of errors related to automatic reference counting mode. I'm going to assume I should be compiling with automatic reference counting OFF -- could someone confirm this for me?

You should not be using automatic reference counting. That is for Objective-C code.

You may have a search path problem, where Xcode can't find the SDL framework and/or headers. Start with adding the path to SDL to Xcode's Framework Search Paths build setting. If that doesn't work, add a path to the Header Search Paths build setting. If you're using Xcode 4, the following article may help you:

Using SDL with Xcode 4


#4930018 Having loads of trouble compiling C++ SDL/OpenGL project on Mac OS X

Posted by szymczyk on 10 April 2012 - 04:06 PM

SDL is not a system framework. You should use quotes instead of angle brackets to include SDL, SDL_image, and SDL_mixer.

SDL has a header file for OpenGL, SDL_opengl.h, that keeps you from having to worry about how to include the OpenGL headers on various operating systems. I suggest including SDL_opengl.h instead of gl.h.

You haven't said how you are trying to compile your code. Are you using Xcode or are you trying to compile using a makefile? If you are using a makefile, you need to link to the Cocoa framework because the Mac version of SDL uses Cocoa. You also need to add the file SDLMain.m to your Xcode project or makefile. SDLMain.m contains glue code that allows you to compile SDL code on Mac OS X.

If you click the link in my signature, you can find a tutorial I wrote on using SDL and OpenGL on Mac OS X. You can also find my blog, which has a category for SDL posts, that could help you.


To any moderator on this board, you may want to move this topic to the APIs and Tools board. The APIs and Tools board houses most SDL questions.


#4908127 Xcode 4 on Lion and SDL 1.2.15

Posted by szymczyk on 31 January 2012 - 01:37 PM

Change the setupWorkingDirectory: method in SDLMain.m so the working directory is the application bundle's Resources folder. You can find code to change the working directory in the following article:

SDL Tips for Mac OS X

Read the section Changing the Working Directory.


#4907751 Xcode 4 on Lion and SDL 1.2.15

Posted by szymczyk on 30 January 2012 - 02:27 PM

The old SDL project templates don't work with Xcode 4. The easiest way to go is to start with a Cocoa application project. For more detailed instructions on how to set up SDL with Xcode 4, read the following article:

Using SDL with Xcode 4


PARTNERS