Difference between revisions of "Compiling for Windows on Linux"
(Fix links) |
(→Option 3: Building from source: Correct filename) |
||
Line 93: | Line 93: | ||
Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. Then compile and install the libraries as follows (they will automatically be downloaded): | Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. Then compile and install the libraries as follows (they will automatically be downloaded): | ||
− | <code>./powder-cross-libs make bzip2 fftw lua pthread regex sdl</code> | + | <code>./powder-cross-libs.sh make bzip2 fftw lua pthread regex sdl</code> |
− | <code>sudo ./powder-cross-libs install bzip2 fftw lua pthread regex sdl</code> | + | <code>sudo ./powder-cross-libs.sh install bzip2 fftw lua pthread regex sdl</code> |
= Compile = | = Compile = |
Revision as of 01:50, 17 February 2012
This is for Linux users to cross-compile to Windows 32-bit.
BEFORE WE START, PLEASE MAKE SURE YOU CAN COMPILE FOR LINUX FIRST!
Contents
Packages
First, install the basic packages needed for cross compiling.
Search for the following in your package manager: mingw32 mingw32-binutils mingw32-runtime
Ubuntu Users
Copy and paste this into your address bar (Firefox):
apt:mingw32,mingw32-binutils,mingw32-runtime"
If it doesn't work, use the following in a terminal:
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
Debian Users
In a terminal:
su -c "apt-get install mingw32 mingw32-binutils mingw32-runtime"
Arch Users
In your Terminal:
su -c 'pacman -S mingw32-{gcc,binutils,runtime}
Libraries
Next, Powder Toy needs a couple of libraries. There are three ways to get them:
- Package repositories. This is usually the easiest way, but not all distributions have MinGW versions of all the required libraries in their package repositories
- Download and extract precompiled libraries. However, this wiki page does not currently have links for all the libraries.
- Compile from source. This can be difficult, but there is a script available to help you. You'll need to use this method if you don't want to distribute DLL files with your executables.
The libraries needed are:
- SDL
- bzip2
- pthread
- libregex (sometimes found under the name libgnurx)
- Lua (optional - if you don't want to use it, remove -DLUACONSOLE from the Makefile)
- FFTW (optional - if you don't want to use it, remove -DGRAVFFT from the Makefile)
Option 1: Package repositories
When using this method, you will usually need to distribute some DLLs to make your builds work. These are normally located in the bin folder where MinGW packages were installed (e.g. /usr/i586-mingw32msvc/bin or /usr/i686-w64-mingw32/bin).
openSUSE users
Some of the required libraries can be found here: https://build.opensuse.org/project/show?project=windows%3Amingw%3Awin32
Repository URL for package manager: http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.4/
Option 2: Precompiled
Download
Download the libraries (this is an incomplete list, update this wiki page if you find links for the other libraries):
- SDL-devel-1.2.14-mingw32.tar.gz from http://www.libsdl.org/
- bzip2-1.0.6-4-mingw32-dev.tar.lzma from MinGW on SourceForge.
- mingw-libgnurx-2.5.1-dev.tar.gz from MinGW on SourceForge
Extract
THE EXTRACTION PROCESS CAN ONLY BE DONE AS ROOT USER. USE AN ALTERNATE WORKSPACE AND CLOSE ALL WINDOWS WHEN FINISHED.
GNOME:
sudo nautilus
-OR-
su -c "nautilus"
\\
XFCE use Thunar instead of Nautilus\\
KDE use Konqueror
The target folder for all extractions is /usr/i586-mingw32msvc (Arch use /usr/i486-mingw32). Everything I'm telling you to extract is a folder and any overwrites or merges should be permitted.
SDL-devel-1.2.14-mingw32.tar.gz
Extract the bin, include and libs folders
bzip2-1.0.6-4-mingw32-dev.tar.lzma
Extract the entire archive.
mingw-libgnurx-2.5.1-dev.tar.gz
Extract the entire archive.
DLLs
These DLLs will need to be distributed with your builds so they work. Or if you're lazy you can just post the URLs and tell everyone else to download them.
- http://tinyurl.com/sdldll - SDL.dll
- http://tinyurl.com/bz2dll - libbz2-2.dll
- http://tinyurl.com/grxdll - libgnurx-0.dll
Option 3: Building from source
This is the method to use if you want to use static linking (so that the executable does not need extra DLL files to run).
Since figuring out all the right commands to cross compile the libraries can be difficult, here is a script that (hopefully) has all the right commands already: https://raw.github.com/jacksonmj/The-Powder-Toy/master/powder-cross-libs.sh
Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. Then compile and install the libraries as follows (they will automatically be downloaded):
./powder-cross-libs.sh make bzip2 fftw lua pthread regex sdl
sudo ./powder-cross-libs.sh install bzip2 fftw lua pthread regex sdl
Compile
Some Makefile changes may be needed.
CC_WIN and WIN_RES should be set to the names of the relevant MinGW programs. These names vary between distributions.
Arch users:
CC_WIN := i486-mingw32-gcc
WIN_RES := i486-mingw32-windres
Change all instances of -llibregex to -llibgnurx
Save, Exit, cd to your powder toy directory and run:
make powder-sse.exe powder-sse2.exe powder-sse3.exe