Compiling wxWidgets with MSYS-MinGW
Note
It may be worthwhile to try Compiling wxWidgets with MinGW first. MSYS adds an extra layer of complexity on top of MinGW that you may not necessarily be interested in, at least in the beginning.
Installing and compiling
MSYS/MinGW provide a very minimal unix-like environment for Windows, not requiring Cygwin.
- First, install MinGW from http://www.mingw.org/download.shtml. If you're using Dev-C++, this was probably already done for you.
- Download MSYS from http://www.mingw.org/download.shtml (NOTE: Please Download&Install The MinGW-5.1.4.EXE Version In The Automated MinGW Section To Skip All Post Install Steps!)
- Install it by running the installer application.
- During the post-install procedure, you'll be asked where MinGW is installed. This is the directory containing the bin/ directory with MinGW files. So if the location of mingw is C:/Dev-Cpp/bin or C:/MinGW/bin, be sure to only give the C:/Dev-Cpp or C:/MinGW portion. The postinstall script only gives you one shot at this so try to get it right the first time. Note the forward slashes. Don't worry if you make a mistake; just go to the postinstall folder and run pi.bat to start over again.
- If you didn't install MinGW in the root directory the installer will fail to find it. In that case you have to manually tell MSYS where to find MinGW. Go to c:\msys\1.0\etc (change the path to suit your installation) and create a new text file. Open it and add the following line:
c:/mingw /mingw
- Replace c:/mingw with your path. In my case it becomes:
C:/MinGWStudio/MinGW /mingw
- Note the forward slashes!
- Rename the file to fstab (with no file extension). If you have file extensions hidden (the Windows default) then you have to turn them on. In Windows explorer go to Tools->folder options. Click on the view tab and turn off 'hide extensions for known file types'
- If you haven't set up your paths, now is a good time to do it. Here is how you do it in Windows XP. Right click on My Computer then select Properties. Click on the advanced tab then the 'environment variables' button. In system variables, look for a variable called path and double click on it. Add the following to the beginning of the value:
c:\mingw\bin;c:\msys\1.0\bin;
- You will probably have to change these values to suit your installation. For instance mine is
C:\MinGWStudio\MinGW;c:\msys\1.0\bin;
- Note the back slashes! Don't delete the existing paths unless you know what you are doing. Make sure MSYS is after the MinGW path. To achieve this in Windows 98 and ME, go to Start/Run and type msconfig. There is a tab called Environment where you can modify the paths and other variables.
- Download the wxWidgets source from https://www.wxwidgets.org/downld2.htm . Find a version relevant to you (I prefer the non-setup version).
- Extract the file to somewhere helpful (C:\wx seems like a good choice, or maybe C:\wx241, or likewise).
- Open an MSYS shell by clicking on the Msys icon.
- change to the directory you installed the wx source to ($ cd c:wx).
The following two commands set up a build directory for your MinGW installation. This allows you to use the same source tree for multiple, separate builds of wxWidgets. You can skip this step, but it will result in the tree being "infected" by Makefiles specific to this build.
- create a new build directory ($ mkdir msw-debug) call it what you like.
- enter that directory ($ cd msw-debug).
- run configure to 'configure' your custom built wxWidgets. Don't forget to add your special flags for anything else you want to turn on or off. ($ ../configure --disable-shared --enable-debug) WxWidgets_Build_Configurations
Note: If you had skipped making a separate build directory, you would need to use ./configure instead of ../configure
- Compile/make your wxWidgets build ($ make).
- Install it into MSYS. This will be helpful for running the 'wx-config' script later ($ make install).
- test your build. If you see a windows application open up, your wxWidgets has built correctly ($ cd samples/minimal; make && minimal.exe).
MinGW Version-Specific Issues
Problems with MinGW 5.1.3
I ran into a problem where the configure script kept outputting the error:
configure: error: cannot guess build type; you must specify one
I fixed it by executing:
$ ../configure --build=x86-winnt-mingw32 or, to remove dependencies: $ ../configure --build=x86-winnt-mingw32 --disable-shared --disable-threads
Maybe that's obvious for some people, but it took me about a day to figure that one out.
See Also
Compiling wxWidgets with MinGW
External Links
An alternate how-to is available at http://max.berger.name/howto/wxWidgets/wxWidgets_MinGW.jsp