title: How to use conan's SDL2 in windows
body: <p>I'm new to compiling with conan in windows and I'm struggling with using SDL2.</p>
  
  <p><a href="https://bitbucket.org/mutcoll/conan-sdl2-hello-world" rel="nofollow">Here</a> there's a hello world that uses conan, which compiles and runs fine in linux doing:</p>
  
  <pre><code>git clone https://bitbucket.org/mutcoll/conan-sdl2-hello-world.git
  cd conan-sdl2-hello-world
  conan install --build=missing
  cmake -G "Unix Makefiles"
  make
  ./bin/test_sdl2
  </code></pre>
  
  <p>but in windows (using git for windows bash, don't know if that's important) the link against SDL2 fails with errors like this: </p>
  
  <pre><code>testspriteminimal.obj : error LNK2019: unresolved external symbol _SDL_GetError referenced in function "int __cdecl LoadSprite(char *,struct SDL_Renderer *)" (?LoadSprite@@YAHPADPAUSDL_Renderer@@@Z) [C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\test_sdl2.vcxproj]
  </code></pre>
  
  <p>the question is: How can I get a successful linking? preferably with shared (SDL2.dll). Thanks to everybody in advance, below there are some details, 
  if anyone needs more details, just ask (for example, putting the whole compilation in pastebin).</p>
  
  <h2>Reproducing the error</h2>
  
  <p>This is my CMakeLists.txt</p>
  
  <pre><code>project(SDL2_test)
  cmake_minimum_required(VERSION 2.8)
  
  include(conanbuildinfo.cmake)
  conan_basic_setup()
  
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")    
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # I think I should do this only if gcc
  
  add_executable(test_sdl2 testspriteminimal.cpp)
  target_link_libraries(test_sdl2 ${CONAN_LIBS})
  </code></pre>
  
  <p>and my conanfile.txt:</p>
  
  <pre><code>[requires]
  SDL2/2.0.3@lasote/stable
  
  [generators]
  cmake
  </code></pre>
  
  <p>these are my settings my <code>.conan/conan.conf</code> (the ones that conan install is using):</p>
  
  <pre><code>[settings_defaults]
  arch=x86_64
  build_type=Release
  compiler=Visual Studio
  compiler.runtime=MD
  compiler.version=14
  os=Windows
  </code></pre>
  
  <p>I'm using these lines after cloning:</p>
  
  <pre><code>conan install --build=missing  # this works fine, compiles SDL2.dll, SDL2.lib, SDL2main.lib
  cmake -G "Visual Studio 14"
  cmake --build .    # this fails
  </code></pre>
  
  <p>that last command fails doing this (even though I can see that it is using the <code>SDL2.lib</code>):</p>
  
  <pre><code>Link:
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\bin\test_sdl2.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:/Users/josemi/.conan/data/SDL2/2.0.3/lasote/stable/package/c85f9b402dd4d46acdf074e1c63b768a41181d7a/lib /LIBPATH:C:/Users/josemi/.conan/data/SDL2/2.0.3/lasote/stable/package/c85f9b402dd4d46acdf074e1c63b768a41181d7a/lib/Debug kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib SDL2.lib SDL2main.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/Users/josemi/Documents/conan/conan-sdl2-hello-world/bin/test_sdl2.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/josemi/Documents/conan/conan-sdl2-hello-world/lib/test_sdl2.lib" /MACHINE:X86 /SAFESEH  /machine:X86 test_sdl2.dir\Debug\testspriteminimal.obj
  </code></pre>
  
  <h3>some more warnings, maybe unrelated</h3>
  
  <p>sdl2 built for x86?</p>
  
  <pre><code>"C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\ALL_BUILD.vcxproj" (destino predeterminado) (1) -&gt;
  "C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\test_sdl2.vcxproj" (destino predeterminado) (3) -&gt;
  
  (Link destino) -&gt;
  C:/Users/josemi/.conan/data/SDL2/2.0.3/lasote/stable/package/c85f9b402dd4d46acdf074e1c63b768a41181d7a/lib\SDL2.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86' [C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\test_sdl2.vcxproj]
  C:/Users/josemi/.conan/data/SDL2/2.0.3/lasote/stable/package/c85f9b402dd4d46acdf074e1c63b768a41181d7a/lib\SDL2main.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86' [C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\test_sdl2.vcxproj]
  </code></pre>
  
  <p>like ~200 warnings like the next one, with C functions:</p>
  
  <pre><code>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdlib.h(354): warning C4514: 'abs': unreferenced inline function has been removed [C:\Users\josemi\Documents\conan\conan-sdl2-hello-world\test_sdl2.vcxproj]
  </code></pre>