Tangent128 / luasdl2

A pure C binding of SDL 2.0 for Lua 5.1, Lua 5.2, and LuaJIT.
ISC License
385 stars 74 forks source link

Compiling on Windows 10 x64 #45

Open Nlcke opened 8 years ago

Nlcke commented 8 years ago

Which exactly SDL2 libraries (e.g. you need SDL2-devel-2.0.4-mingw.tar.gz, SDL2_image-2.0.1.zip, etc) do I need to download to make with Cmake and then compile with Mingw? Do I need Mingw32 or Mingw64? Which version of Cmake do I need?

Tangent128 commented 8 years ago

Windows build scripts have not been tested lately, so you may need some trial and error (if you have to edit the scripts, please send a pull request if the fix looks generally applicable)

You will want the devel- versions of the libraries, with the same verison number for the core and image/ttf/etc libraries. Latest version is probably safe.

If you want to produce 64-bit binaries, I assume you would want Mingw64, but I have not used it lately. Mingw32 would presumably still work, but would produce 32-bit binaries.

pgerhardy commented 7 years ago

Since I spent a better part of an evening trying to compile luasdl for windows, and finally suceeded, I thought I'd share my findings. Perhaps they can be helpful to others.

I managed to compile on Windows 7 with the TDM-GCC-64 5.1.0 for my compiler toolchain (generate "MinGW Makefiles"). I tried generating for "Visual Studio" but could not get that to work. These were the steps:

  1. Download lua sources (5.3.2, but luajit should work too), fetch luasdl from git, place them each in their separate directory.
  2. Build lua 5.3.2 ("mingw32-make mingw" in the src-directory)
  3. Download Visual C++ development libraries for various SDL modules (could not get this too work with the mingw32 development libraries)
  4. Setup environment variables (LUA_DIR to lua 5.3.2 src-directory, SDLDIR, SDLIMAGEDIR etc to the respective directories that hold the "x64" dlls.
  5. In the "build" directory (as described in the "Build from sources" section on wiki), run "cmake .. -G "MinGW Makefiles" -DWITH_LUAVER=53".
  6. Manually add the full path to the "lua53.dll" to the variuous linker statements (link.txt files), something like "<path of lua 5.3.2>/src/lua53.dll". For some reason that is not included by cmake and one gets error messages about unresolved references.
  7. Run mingw32-make. Copy lua binaries (exe and dll), SDL dlls and the newly compiled dlls to the install location.
  8. Enjoy!

I tested running various tutorial snippets (including bouncing logo) and so far everything works. If I missed something obvious shame on me. Perhaps someone proficient in cmake (my future self?) can fix the linker statement generation.

tffdev commented 5 years ago

I spent a good afternoon doing this too, pretty much the same as pgerhardy but with ran in to a lot of my own issues. If anyone comes across this, just to save them time, here's the compiled 64 bit bins (you'll need the 64 bit Lua interpreter): lua-sdl2.zip (64 BIT)