Alex Rivera | Logout

Simply including SDL header causes linker error

Asked 2011-08-15T23:27:25.313
12

I was going to migrate my game from glut to sdl.

It's working perfectly in glut but I wanted to use some sdl features.

So I go into my project properties, under the targets header I click the program that will be compiled, build phases, link binary with libraries, add SDL.framework

The exact same as I have done for OpenGL.framework and GLUT.framework

However when I add: #include <SDL/SDL.h> it comes up with a linker error when I try to build:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
      __start in crt1.o
     (maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Googling simply leads to a fair few results, but no real explanations.

Edit
Report

1 Answer

2

I have found that when I get the error :

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)

I have forgotten to go to Project -> Build Phases -> Compile Sources and add SDLMain.m to the list. This solved the problem for me right away.

answered 2013-05-30T00:05:42.967

Your Answer