Setting up a MinGW-w64 build environment: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
* Download and install the latest Python 2.7 release. We used the 64-bit version if 2.7.5, [http://www.python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi python-2.7.5.amd64.msi] from [http://www.python.org/download/ this page]. If you want to build Python extensions, as we do with ASCEND, then you need to use the 64-bit version of Python with the 64-bit C/C++ compiler, or the 32-bit version of Python with the 32-bit C/C++ compiler. If you install the 32-bit version of Python, we suggest you select the installation directory as <tt>c:\Python27_32</tt>, whereas for the 64-bit version, use the default <tt>c:\Python27</tt>.
* Download and install the latest Python 2.7 release. We used the 64-bit version if 2.7.5, [http://www.python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi python-2.7.5.amd64.msi] from [http://www.python.org/download/ this page]. If you want to build Python extensions, as we do with ASCEND, then you need to use the 64-bit version of Python with the 64-bit C/C++ compiler, or the 32-bit version of Python with the 32-bit C/C++ compiler. If you install the 32-bit version of Python, we suggest you select the installation directory as <tt>c:\Python27_32</tt>, whereas for the 64-bit version, use the default <tt>c:\Python27</tt>.
* Download and install the [https://projects.gnome.org/gedit/ gedit] text editor for Windows. We used this package: [http://ftp.gnome.org/pub/GNOME/binaries/win32/gedit/2.30/gedit-setup-2.30.1-1.exe gedit-setup-2.30.1-1.exe] (32-bit)
* Download and install the [https://projects.gnome.org/gedit/ gedit] text editor for Windows. We used this package: [http://ftp.gnome.org/pub/GNOME/binaries/win32/gedit/2.30/gedit-setup-2.30.1-1.exe gedit-setup-2.30.1-1.exe] (32-bit)
* Download and install NSIS. We used [http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download nsis-2.46-setup.exe].


== MinGW-w64 ==
== MinGW-w64 ==
Line 42: Line 43:
* In Windows Explorer, navigate to <tt>c:\mingw\msys\postinstall</tt> and run the batch-file <tt>pi</tt> (aka <tt>pi.bat</tt>). This will pop up a console with some questions in it. You need to say that you have installed MinGW and that its location is <tt>c:/mingw/64</tt>. The script should complete with a few minor messages.
* In Windows Explorer, navigate to <tt>c:\mingw\msys\postinstall</tt> and run the batch-file <tt>pi</tt> (aka <tt>pi.bat</tt>). This will pop up a console with some questions in it. You need to say that you have installed MinGW and that its location is <tt>c:/mingw/64</tt>. The script should complete with a few minor messages.


* Open gedit and check the contents of the file <tt>c:\mingw\msys\etc\fstab</tt> (no filename extension). It should contain simply the text as shown here:
* Open gedit (from the Start menu) and check the contents of the file <tt>c:\mingw\msys\etc\fstab</tt> (no filename extension). It should contain simply the text as shown here:
  c:/mingw/64  /mingw
  c:/mingw/64  /mingw


Line 50: Line 51:


[[Image:msys-windows7-test.png]]
[[Image:msys-windows7-test.png]]
* In gedit, open the file <tt>c:\mingw\msys\home\'''yourusername'''\.profile</tt> (no file extension). In that file, enter the following text, and save the resulting file.
  export PATH=$PATH:/c/Python:/c/Python/Scripts:/c/Program\ Files\ \(x86\)/gedit/bin
== SCons ==
* Download the latest stable [http://www.scons.org SCons] tarball file. We used http://prdownloads.sourceforge.net/scons/scons-2.3.0.tar.gz scons-2.3.0.tar.gz]. Move the saved file to the directory <tt>c:\mingw\msys\home\'''yourusername'''</tt>.
* Unpack, build and install SCons using the following commands, typed into a new MSYS window.
tar zxvf scons-2.3.0.tar.gz
python setup.py bdist_wininst
start dist/scons-2.3.0-win-amd64.exe
* Step through the installer process, then return to your MSYS window and type
copy /c/Python27/Scripts/scons.py /c/Python27/Scripts/scons
* Test that SCons is working by typing <tt>scons --version</tt>. You should get a copyright message including text to show that the you have version 2.3.0 of SCons running.


== Dependency Walker ==
== Dependency Walker ==


* Download the 'x64' version of [http://www.dependencywalker.com/ Dependency Walker]. We downloaded this file: [http://www.dependencywalker.com/depends22_x64.zip depends22_x64.zip].
* Download the 'x64' version of [http://www.dependencywalker.com/ Dependency Walker]. We downloaded this file: [http://www.dependencywalker.com/depends22_x64.zip depends22_x64.zip]. If you are also building 32-bit applications, you will also need the i686 version of Dependency Walker.
* Unpack the .exe and .dll files into the directory <tt>c:\mingw\64\bin</tt>, for the 64-bit version and/or <tt>c:\mingw\32\bin for the 32-bit version.
 




--- ongoing ---
--- ongoing ---

Revision as of 06:45, 9 August 2013

This page documents our recommended software build environment for Windows, tested on Windows 7 Professional 64-bit. The build environment is capable of building both 64-bit and 32-bit software, although some manual editing of configuration files is required to switch between the two. We will be evolving these recommendations over time, so check back again to see more. With some fairly obvious changes, these instructions will also work for Windows XP 32-bit, but you can't (easily) build 64-bit Python extensions on that platform.

The suggested build environment includes

  • 7-zip file archive tool
  • Python 2.7.5 scripting language
  • GCC 4.x compiler suite
  • SCons 2.3.0 software build tool
  • gedit 2.30.1 text editor
  • SWIG 2.0.10 wrapper interface generator
  • NSIS installation package builder
  • Dependency Walker 2.2 library/program file dependency checker

These steps were completed by a user with adminstrator privileges. It is knows the Python, MinGW etc can be installed by non-adminstrator users, but we haven't yet tested that scenario, unfortunately.

First steps

  • Download and install the 64-bit version of 7-zip. We used the 64-bit version, 7z920-x64.msi.
  • Download and install the latest Python 2.7 release. We used the 64-bit version if 2.7.5, python-2.7.5.amd64.msi from this page. If you want to build Python extensions, as we do with ASCEND, then you need to use the 64-bit version of Python with the 64-bit C/C++ compiler, or the 32-bit version of Python with the 32-bit C/C++ compiler. If you install the 32-bit version of Python, we suggest you select the installation directory as c:\Python27_32, whereas for the 64-bit version, use the default c:\Python27.
  • Download and install the gedit text editor for Windows. We used this package: gedit-setup-2.30.1-1.exe (32-bit)
  • Download and install NSIS. We used nsis-2.46-setup.exe.

MinGW-w64

MinGW-w64 (Minimalist GNU for Windows, 64-bit) is a version of the earlier MinGW version of GCC (GNU Compiler Collection: C, C++ and Fortran compilers and associated tools) that was carefully extended to include support for 64-bit Windows. It works with both 32-bit and 64-bit Windows, but you need to make sure you download the right package according to which platform you want to target (and which platform you are building on, too). We're aiming for the following file structure:

c:
  \mingw
        \64
        \32
        \msys

Download x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z, which provides you with the 64-bit MinGW-w64 GCC compiler targeting 64-bit Windows. Once you have the downloaded file, right-click it, select "7-zip" and "Open archive". Double click 'mingw64', then select all of the sub-files and subfolders under there (bin, lib, include, and the rest). Click "Extract" and type in c:\mingw\64. Then check in Windows Explorer that the files have appeared as expected. You should have c:\mingw\64\bin, c:\mingw\64\lib, and so on.

Optional. If you also want to be able to build 32-bit stuff, download i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z and extract the contents, using the same method above, into c:\mingw\32. This is the compiler for making 32-bit packages, and it only requires 32-bit Windows to run, so all of the above should work fine even on native 32-bit Windows XP, for example (but for 32-bit windows, you need to also select 32-bit Python and 7-zip above).

MSYS

MSYS provides a command-line interface to MinGW that looks and feels like Linux/Unix terminal and the Mac OSX terminal. It includes a large number of very useful utilities like 'wget', 'grep', and many others which will be useful when building software with GCC.

  • Download MSYS-20111123.zip and extract the contents into c:\mingw\msys. This can be done by locating the downloaded MSYS-20111123.zip file, double-clicking it, then when you see the folder 'msys', copy it and paste it into the directory c:\mingw (navigate into c:\ then mingw then paste).
  • In Windows Explorer, navigate to c:\mingw\msys\postinstall and run the batch-file pi (aka pi.bat). This will pop up a console with some questions in it. You need to say that you have installed MinGW and that its location is c:/mingw/64. The script should complete with a few minor messages.
  • Open gedit (from the Start menu) and check the contents of the file c:\mingw\msys\etc\fstab (no filename extension). It should contain simply the text as shown here:
c:/mingw/64   /mingw
  • In Windows Explorer, navigate to c:\mingw\msys and create a shortcut to the batch-file msys.bat. Right-click the resulting shortcut and select to change its icon to c:\mingw\msys\msys.ico. Move the resulting shortcut to your desktop.
  • Test that MSYS is working correctly:

  • In gedit, open the file c:\mingw\msys\home\yourusername\.profile (no file extension). In that file, enter the following text, and save the resulting file.
 export PATH=$PATH:/c/Python:/c/Python/Scripts:/c/Program\ Files\ \(x86\)/gedit/bin

SCons

tar zxvf scons-2.3.0.tar.gz
python setup.py bdist_wininst
start dist/scons-2.3.0-win-amd64.exe 
  • Step through the installer process, then return to your MSYS window and type
copy /c/Python27/Scripts/scons.py /c/Python27/Scripts/scons
  • Test that SCons is working by typing scons --version. You should get a copyright message including text to show that the you have version 2.3.0 of SCons running.

Dependency Walker

  • Download the 'x64' version of Dependency Walker. We downloaded this file: depends22_x64.zip. If you are also building 32-bit applications, you will also need the i686 version of Dependency Walker.
  • Unpack the .exe and .dll files into the directory c:\mingw\64\bin, for the 64-bit version and/or c:\mingw\32\bin for the 32-bit version.


--- ongoing ---