title: Compiling with 64-bit MinGW on Code::Blocks
body: <p>I'm trying to set up my Code::Blocks installation to work with the SDL2 graphics API.  As the documentation suggests, once I had everything installed and specified correctly, I tried the 
  <code>SDL_Init(SDL_INIT_EVERYTHING)</code> test, as:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;SDL2/SDL.h&gt;
  
  int main (int argc, char *argv[])
  {
      if (SDL_Init(SDL_INIT_EVERYTHING) &lt; 0)
      {
          printf("\nSDL2 could not be initialized! Code: %s\n", SDL_GetError());
      }
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>However, I got the following errors:</p>
  
  <pre><code>...in function 'SDL_Main':
  undefined reference to `SDL_Init`
  undefined reference to `SDL_GetError`
  undefined reference to 'WinMain@16'
  </code></pre>
  
  <p>I looked these errors up and they seem to be due to CodeBlocks using a 32-bit compiler, but I'm using the 64-bit SDL2 library. Which makes sense, as my linked options are:</p>
  
  <pre><code>-lmingw32 -lSDL2main -lSDL2
  </code></pre>
  
  <p>So, I used MinGW's <code>WinBuilds</code> tool to download the 64-bit MinGW fork, which gave me a massive amount of files in a new <code>/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/...</code> folder. Then I went to CodeBlocks' <code>Settings -&gt; Compiler -&gt; Toolchain Executables</code> and pointed the respective compiler executables at the exe's in <code>bin</code>. My first thought was to then change <code>-lmingw32</code> to <code>-lmingw64</code>, but this doesn't work. I get the error:</p>
  
  <pre><code>cannot find -lmingw64
  </code></pre>
  
  <p>At this point I'm not sure what I've done correctly, incorrectly, what is broken/working etc. and would really appreciate any help possible.</p>
  
  <p>It may also be worth noting that I extracted the 64-bit compiler to <code>C:\MinGW</code> and pointed CodeBlocks at <code>C:\MinGW\bin</code> as the compiler installation directory. When I click <code>Auto-Detect</code>, it seems happy enough and states it has automatically found the GCC compiler in that location. Therefore, it must be my <code>-lmingw64</code> flag that is wrong, or something else I have specified.</p>
  
  <p>Edit: The 64-bit compiler was set up and detected correctly but continued to produce errors relating to <code>SDL</code> functions:</p>
  
  <pre><code>||=== Build: Debug in Initialization_Test (compiler: GNU GCC Compiler) ===|
  obj\Debug\main.o||In function `SDL_main':|
  C:\C\SDL_C_Graphics\Init_Test\Initialization_Test\main.cpp|8|undefined reference to `_SDL_Init'|
  C:\C\SDL_C_Graphics\Init_Test\Initialization_Test\main.cpp|10|undefined reference to `_SDL_GetError'|
  C:\C\SDL_C_Graphics\Init_Test\Initialization_Test\main.cpp|10|undefined reference to `_printf'|
  obj\Debug\main.o||In function `__tcf_0':|
  c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream|74|undefined reference to `__ZNSt8ios_base4InitD1Ev'|
  obj\Debug\main.o||In function `__static_initialization_and_destruction_0':|
  c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream|74|undefined reference to `__ZNSt8ios_base4InitC1Ev'|
  c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream|74|undefined reference to `_atexit'|
  C:\SDL_Dev\SDL2-2.0.12\x86_64-w64-mingw32\lib\libSDL2main.a(SDL_windows_main.o)||In function `main_getcmdline':|
  \Users\valve\release\SDL\SDL2-2.0.12-source\foo-x64\..\src\main\windows\SDL_windows_main.c|71|undefined reference to `SDL_main'|
  ||error: ld returned 1 exit status|
  ||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
  </code></pre>
  
  <p>Command CodeBlocks may be executing for compilation, in separate log window:</p>
  
  <pre><code>x86_64-w64-mingw32-g++.exe -LC:\SDL_Dev\SDL2-2.0.12\x86_64-w64-mingw32\lib -LC:\SDL_Dev\SDL2-2.0.12\x86_64-w64-mingw32\lib -LC:\SDL_Dev\SDL_Img\SDL2_image-2.0.5\x86_64-w64-mingw32\lib -LC:\SDL_Dev\SDL_Mixer\SDL2_mixer-2.0.4\x86_64-w64-mingw32\lib -L"C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib" -o bin\Debug\Initialization_Test.exe obj\Debug\main.o  -lmingw32 -lSDL2main -lSDL2  -lmingw32 -lSDL2main -lSDL2.dll -luser32 -lgdi32 -lwinmm -ldxguid
  C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `obj\Debug\main.o' is incompatible with i386:x86-64 output
  </code></pre>