views:

840

answers:

1

When I try to use SDL in my c++ program, I get the following:

> g++ minimal.cpp SDLMain.m
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Here's my minimal.cpp:

#include <SDL/SDL.h>
int main(int argc, char **argv) {
    return 0;
}

What I could gather from http://www.libsdl.org/faq.php?action=listentries&amp;category=7 was that by including SDL.h, it renames my main function through some macro magic. But then SDLMain.m is supposed to make things right again by calling that renamed function. But somehow that is not happening?

I'm running Leopard.

Note that this is a different issue from question 550455.

+1  A: 

Solution was to use the SDLMain.m file included in SDL-devel-1.2.14-extras.dmg from the SDL homepage. For some reason the one I was using before had mysteriously stopped working. Here's my working compile command:

g++ -framework SDL -framework Cocoa -I/usr/local/include/SDL/ minimal.cpp "/Library/Application Support/Developer/Shared/Xcode/Project Templates/SDL Application/SDLMain.m"
Bemmu