Reputation: 111
This problem has been already asked but after an extensive search on Google I've found no questions related to the 1.2.15 version of SDL with the last version of XCODE so please allow me to post the problem (again) and the solution I've found for those up-to-date version (30th September 2015).
Config:
OSX 10.10.5 XCODE 7.0 SDL 1.2.15
How to reproduce:
Copied the SDL.Framework to /Library/Frameworks as explained on the readme.txt
On XCODE Template > Building settings > Framework Search path as /Library/Frameworks
I included the SDL framework on the main.cpp file as follows:
#include <SDL/SDL.h>
When I try to compile and test I get an error because of a double declaration of class main...
This is the error message:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)
This how I solved it:
I checked and saw that SDL.h is including all the following files:
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_audio.h"
#include "SDL_cdrom.h"
#include "SDL_cpuinfo.h"
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_loadso.h"
#include "SDL_mutex.h"
#include "SDL_rwops.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "SDL_video.h"
#include "SDL_version.h"
#include "begin_code.h"
One of them is SDL_main.h and on that file we see:
#define main SDL_main
This line is producing a conflict with the class main on main.cpp, commenting that line on SDL_main.h or commenting the line #include "SDL_main.h" on SDL.h solves the issue. I'm a noob on C++ (I just learn it at University many years ago) but from other languages I know that "hacking" a library is a very bad practice... though it seems to be a particular compatibility problem with MAXOSX and I really want to use XCODE...
Please correct and comment, justify yes or no, as I'm on a learning process.
Cheers!
Upvotes: 0
Views: 393
Reputation: 1
I've resolved the problem with #undef main before the declaration of the main function.
Upvotes: 0