Difference between revisions of "Compiling for Windows on Linux"
(Update list of libraries, add a link to a script to compile the libraries from source) |
|||
Line 1: | Line 1: | ||
This is for Linux users to cross-compile to Windows 32-bit. | This is for Linux users to cross-compile to Windows 32-bit. | ||
− | + | '''BEFORE WE START, PLEASE MAKE SURE YOU CAN COMPILE FOR LINUX FIRST!''' | |
− | + | = Packages = | |
+ | First, install the basic packages needed for cross compiling. | ||
− | |||
Search for the following in your package manager: | Search for the following in your package manager: | ||
''mingw32 mingw32-binutils mingw32-runtime'' | ''mingw32 mingw32-binutils mingw32-runtime'' | ||
− | '''Ubuntu Users | + | '''Ubuntu Users''' |
− | Copy and paste this into your address bar ( | + | Copy and paste this into your address bar (Firefox):<br> |
− | ''apt:mingw32,mingw32-binutils,mingw32-runtime | + | ''apt:mingw32,mingw32-binutils,mingw32-runtime" |
If it doesn't work, use the following in a terminal:<br> | If it doesn't work, use the following in a terminal:<br> | ||
Line 24: | Line 24: | ||
<code>su -c 'pacman -S mingw32-{gcc,binutils,runtime}</code> | <code>su -c 'pacman -S mingw32-{gcc,binutils,runtime}</code> | ||
− | == | + | = 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): | ||
+ | |||
+ | * [http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz SDL-devel-1.2.14-mingw32.tar.gz] from [http://www.libsdl.org/ http://www.libsdl.org/] | ||
+ | * [http://sourceforge.net/projects/mingw/files/MinGW/bzip2/1.0.6-1/bzip2-1.0.6-1-mingw32-src.tar.lzma/download bzip2-1.0.5-2-mingw32-dev.tar.lzma] from [http://sourceforge.net/projects/mingw/files/MinGW/bzip2/release%201.0.5-2/ MinGW on SourceForge]. | ||
+ | * [http://sourceforge.net/project/mingw/files/Other/UserContributed/regex/mingw-regex-2.5.1/mingw-libgnurx-2.5.1-dev.tar.gz/download mingw32-libgnurx-2.5.1-dev.tar] from [http://sourceforge.net/projects/mingw/files/UserContributed/regex/mingw-regex-2.5.1/ MinGW on SourceForge] | ||
+ | |||
+ | === Extract === | ||
'''THE EXTRACTION PROCESS CAN ONLY BE DONE AS ROOT USER. USE AN ALTERNATE WORKSPACE AND CLOSE ALL WINDOWS WHEN FINISHED.''' | '''THE EXTRACTION PROCESS CAN ONLY BE DONE AS ROOT USER. USE AN ALTERNATE WORKSPACE AND CLOSE ALL WINDOWS WHEN FINISHED.''' | ||
Line 43: | Line 67: | ||
KDE use Konqueror | KDE use Konqueror | ||
− | The target folder for all extractions is /usr/i586-mingw32msvc (Arch use /usr/i486-mingw32) | + | 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. |
− | 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 | Extract the bin, include and libs folders | ||
− | + | ==== bzip2-1.0.5-2-mingw32-dev.tar.gz ==== | |
Extract the entire archive. | Extract the entire archive. | ||
− | + | ==== mingw32-libgnurx-2.5.1-dev.tar ==== | |
Extract the entire archive. | Extract the entire archive. | ||
− | + | === DLLs === | |
− | These DLLs will need to be distributed with your builds so they work. Or if | + | 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): | ||
+ | |||
+ | <code>./powder-cross-libs make bzip2 fftw lua pthread regex sdl</code> | ||
+ | |||
+ | <code>sudo ./powder-cross-libs install bzip2 fftw lua pthread regex sdl</code> | ||
+ | |||
+ | = Compile = | ||
Some Makefile changes may be needed. | 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: | ||
− | <code> | + | <code>CC_WIN := i486-mingw32-gcc<br> |
WIN_RES := i486-mingw32-windres</code> | WIN_RES := i486-mingw32-windres</code> | ||
Line 75: | Line 110: | ||
Save, Exit, cd to your powder toy directory and run: | Save, Exit, cd to your powder toy directory and run: | ||
− | <code> | + | <code>make powder-sse.exe powder-sse2.exe powder-sse3.exe</code> |
[[Category:Development]] | [[Category:Development]] |
Revision as of 01:08, 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.5-2-mingw32-dev.tar.lzma from MinGW on SourceForge.
- mingw32-libgnurx-2.5.1-dev.tar 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.5-2-mingw32-dev.tar.gz
Extract the entire archive.
mingw32-libgnurx-2.5.1-dev.tar
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 make bzip2 fftw lua pthread regex sdl
sudo ./powder-cross-libs 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