Using Makefiles to compile wxWidgets
|This article applies to the following versions|
|Status: Out of Date|
Using the Makefiles that come with wxWidgets
The following instructions are based on this forum post.
Setting up MinGW
- Download the latest version of MinGW from its SourceForge page.
- The following packages are required:
- You can download and unzip these manually, or use the automated installer.
- After installation your MinGW directory should contain the subdirectories: "bin", "doc", "include", "info", "lib", "libexec", "man" and "mingw32".
- To use MinGW from the windows command shell, various environment variables must be set. The easiest method to do this is to create a batch script.
- Copy the following code into a text file and save it as "ConfigureMinGW.bat".
- If you installed MinGW to a location other than the default location "C:\MinGW" substitute that for "C:\MinGW". If your path has spaces in it, surround it with double quotes.
@echo off set path=C:\MinGW\bin;%PATH% set LIBRARY_PATH=C:\MinGW\lib set C_INCLUDE_PATH=C:\MinGW\include set CPLUS_INCLUDE_PATH=C:\MinGW\include\c++\3.4.5;C:\MinGW\include\c++\3.4.5\backward;C:\MinGW\include\c++\mingw32;C:\MinGW\include
- Open a command shell with the "Command Prompt" shortcut from the "Accessories" menu and run your batch script by entering its path.
- Alternatively you can create a shortcut that opens a command shell and runs the script automatically. Copy your script to the MinGW folder and create a new shortcut giving the following as the "location".
cmd /K C:\MinGW\ConfigureMinGW.bat
- Test your MinGW console with the command "gcc -v". If you are shown some information on the version of the GCC, you are successfully running the compiler.
Compiling the wxWidgets Libraries
- Download and install the wxWidgets package.
- Configure according to your requirements, the file "config.gcc" in the directory "build\msw" in your wxWidgets folder. For flags, 0 means "disabled" and 1 means "enabled".
- For example, to enable unicode support, change the line "UNICODE = 0" to "UNICODE = 1".
- Set up a command shell configured to use MinGW as described above.
- Change directory to the directory "build\msw" in your wxWidgets folder using the cd command.
- For example, if you installed wxWidgets to "C:\wxWidgets":
- If you are using Windows XP, you must now start a unix-like shell such as "sh" or "bash". The reason is that cmd.exe (the native Windows command processor) will interpret several commands such as "mkdir" as being internal commands, which get preference over programs such as "mkdir.exe". The makefile expects "mkdir" to behave in the unix way, otherwise you will get strange error messages. By starting "sh" or "bash", the behaviour of "cmd.exe" won't interfere.
- Compile wxWidgets with the following command.
mingw32-make -f makefile.gcc