title: libSDL, CMake and Mac OS X Lion
body: <p>I'm trying to compile a cmake project on my mac, but it depends on the SDL framework. I installed this framework and after cmake then reported to me libSDL was not found I set following export variables myself (as suggested by cmake):</p>
  
  <pre><code>export SDL_INCLUDE_DIR=/Library/Frameworks/SDL.framework/
  export SDLIMAGE_LIBRARY=/Library/Frameworks/SDL_image.framework/
  export SDLIMAGE_INCLUDE_DIR=/Library/Frameworks/SDL_image.framework/Headers
  </code></pre>
  
  <p>Now cmake does it job, but when I run make, I get the following message:</p>
  
  <pre><code>Mats-MBP:build mats$ make
  Linking CXX executable SDLExample
  Undefined symbols for architecture i386:
   "_main", referenced from:
       start in crt1.10.6.o
      (maybe you meant: _SDL_main)
  ld: symbol(s) not found for architecture i386
  collect2: ld returned 1 exit status
  make[2]: *** [src/SDLExample] Error 1
  make[1]: *** [src/CMakeFiles/SDLExample.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>I get this for both i386 and x86_64. What did I forget?</p>
  
  <p><strong>EDIT:</strong> these are the file contents:</p>
  
  <pre><code>Mats-MBP:build mats$ cat ../src/main.cpp 
  /**
   * @file main.cpp
   *
   * A simple example-program to help you out with using SDL for 2D graphics.
   *
   * @author przemek
   */
  
  #include &lt;iostream&gt;
  #include &lt;stdexcept&gt;
  #include &lt;SDL.h&gt;
  #include &lt;SDL_image.h&gt;
  
  using namespace std;
  
  int main(int argc, char* argv[]) {
      try {
          // Try to initialize SDL (for video)
          if (SDL_Init(SDL_INIT_VIDEO) != 0) {
              throw runtime_error("Couldn't init SDL video!");
          }
          // Create a double-buffered screen surface:
          SDL_Surface* screen = SDL_SetVideoMode(800, 600, 24, SDL_DOUBLEBUF/* |     SDL_FULLSCREEN*/);
          if (!screen) {
              throw runtime_error("Couldn't set SDL video mode!");
          }
  
          // Use SDL_image library to load an image:
          SDL_Surface* image = IMG_Load("image.png");
  //      SDL_Surface* image = IMG_Load("image.tga");
          if (!image) {
              throw runtime_error(SDL_GetError());
          }
  
          // "Pump" SDL events like keyboard presses and get the keystate:
          SDL_PumpEvents();
          Uint8* keyState = SDL_GetKeyState(0);
  
          // loop until user presses escape:
          while (!keyState[SDLK_ESCAPE]) {
              // Display a game background:
          SDL_Rect src, dst;          // Source and destination rectangles
          src.x = 0;
          src.y = 0;
          src.w = image-&gt;w;
          src.h = image-&gt;h;
          dst.x = 100;
          dst.y = 50;
          dst.w = image-&gt;w;
          dst.h = image-&gt;h;
          // Copy the image from 'image' to 'screen' surface
          SDL_BlitSurface(image, &amp;src, SDL_GetVideoSurface(), &amp;dst);
  
          // Flip surfaces (remember: double-buffering!) and clear the back buffer:
          SDL_Flip(screen);
          SDL_FillRect(screen, 0, 0);
  
          // Get new keyboard state:
          SDL_PumpEvents();
          keyState = SDL_GetKeyState(0);
      }
  
      // Free the screen surface &amp; quit SDL
      SDL_FreeSurface(screen);
      SDL_Quit();
  } catch (runtime_error&amp; e) {
      cout &lt;&lt; e.what() &lt;&lt; endl;
      SDL_Quit();
  }
  
  return 0;
  }
  </code></pre>