title: Error when Linking SDL2 using Clang on Windows "LNK1561: entry point must be defined"
body: <p>I am trying to use clang on Windows to compile and link an SDL2 application.</p>
  
  <p>The reason for this is to try and keep my development environment consistent with other team members who are using OSX with XCode (compiling with clang). Since the Visual C++ compiler is much less strict than the clang compiler I could potentially be committing changes that will not compile under clang. </p>
  
  <p>I would prefer not to have to install VS 2015 to use the experimental LLVM build environment: (link removed)</p>
  
  <p>I have installed the LLVM/clang tools on windows (not built from source, just downloaded binaries from here: (link removed)) and can successfully build and run a "hello world" console application using clang. </p>
  
  <p>What I would like to do, is to have a batch file that allows me to build and link with clang periodically to make sure my code will be safe to commit. </p>
  
  <p>When linking even a simple single file SDL2 application, I receive the following linker error: </p>
  
  <pre><code>LINK : fatal error LNK1561: entry point must be defined
  clang++.exe: error: linker command failed with exit code 1561 (use -v to see invocation)
  </code></pre>
  
  <p>This thread suggests setting the Linker Subsystem <a href="https://stackoverflow.com/questions/18672303/sdl2-lnk1561-entry-point-must-be-defined">SDL2: LNK1561: entry point must be defined</a> although I'm not sure how to do that when compiling from the command line. As I understand, the default should be CONSOLE when not specified. </p>
  
  <p>My main entry point function is in the form int main(int argc, char* argv[]) as per this thread: <a href="https://stackoverflow.com/questions/11976084/why-sdl-defines-main-macro">Why SDL defines main macro?</a></p>
  
  <p>Here is the bat file I am using:</p>
  
  <pre><code>CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
  clang++ -std=c++11 main.cpp -I./include/SDL2 -L./lib -lSDL2main -lSDL2
  </code></pre>
  
  <p>The include and library directories are correct as far as I can tell. The linker can find the libraries and the compiler can see the include files. </p>
  
  <p>To keep things simple, the code I am using to test the compiler/linker has been pulled straight from lazy foo's intro tutorial found here: <a href="http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php" rel="noreferrer">http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php</a> </p>
  
  <pre><code>/*This source code copyrighted by Lazy Foo' Productions (2004-2015)
  and may not be redistributed without written permission.*/
  
  //Using SDL and standard IO
  #include &lt;SDL.h&gt;
  #include &lt;stdio.h&gt;
  
  //Screen dimension constants
  const int SCREEN_WIDTH = 640;
  const int SCREEN_HEIGHT = 480;
  
  int main( int argc, char* args[] )
  {
      //The window we'll be rendering to
      SDL_Window* window = NULL;
  
      //The surface contained by the window
      SDL_Surface* screenSurface = NULL;
  
      //Initialize SDL
      if( SDL_Init( SDL_INIT_VIDEO ) &lt; 0 )
      {
          printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
      }
      else
      {
          //Create window
          window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
          if( window == NULL )
          {
              printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
          }
          else
          {
              //Get window surface
              screenSurface = SDL_GetWindowSurface( window );
  
              //Fill the surface white
              SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface-&gt;format, 0xFF, 0xFF, 0xFF ) );
  
              //Update the surface
              SDL_UpdateWindowSurface( window );
  
              //Wait two seconds
              SDL_Delay( 2000 );
          }
      }
  
      //Destroy window
      SDL_DestroyWindow( window );
  
      //Quit SDL subsystems
      SDL_Quit();
  
      return 0;
  }
  </code></pre>
  
  <p>Does anyone know why I would be receiving this linker error when linking SDL using clang under windows?</p>