Difference between revisions of "Compiling wxWidgets (MSW) 2.8.12 on Windows using makefile.gcc"

From Code::Blocks
m (Mention Direct2D and newer wxWidgets versions.)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.
 
These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.
 +
 +
The same instructions are valid for newer versions of wxWidgets, just replace 2.8.12 with the version you are using (p.e. 3.2.3).
  
 
== Installing MinGW ==
 
== Installing MinGW ==
Line 15: Line 17:
  
 
'''NOTE:''' For the remainder of these instructions we call the MinGW directory ''<MINGW>''. You have to change it to your corresponding directory (e.g. "C:\MinGW").
 
'''NOTE:''' For the remainder of these instructions we call the MinGW directory ''<MINGW>''. You have to change it to your corresponding directory (e.g. "C:\MinGW").
 +
 +
'''NOTE:''' If you intend to compile C::B itself with this wxWidgets version then you must edit <WXWIN>\include\wx\msw\setup_0.h (or setup.h if the former does not exist), locate the line defining wxUSE_GRAPHICS_DIRECT2D and change the assigned value to 1. Do not start compilation before changing this or you will waste a lot of time fixing this.
  
 
== Checking make Version ==
 
== Checking make Version ==
Line 43: Line 47:
  
 
Patience. This step takes time. Make sure there was no compilation error before you continue.
 
Patience. This step takes time. Make sure there was no compilation error before you continue.
 +
 +
== Errors while building wxWidgets ==
 +
Navigate to the folder build/msw inside wxWidgets directory. In this folder is a text file named config.gcc which you can edit with notepad to control the build options. There are two lines to note, CFLAGS ?= and CXXFLAGS ?=. The options given here will go in either or both of those lines.
 +
 +
If your linker runs out of memory while building use:
 +
 +
-fno-keep-inline-dllexport
 +
 +
If your compiler errors out, usually referencing monotree.dll or similar:
 +
 +
-D_WIN32_IE=0x0603
 +
 +
To silence warnings that can significantly slow down the compilation process:
 +
 +
-Wno-unused-local-typedefs
 +
 +
and
 +
 +
-Wno-deprecated-declarations
 +
 +
All of these options apply to both <tt>CFLAGS</tt> and <tt>CXXFLAGS</tt> so the two lines containing all the options would look like this:
 +
 +
  CFLAGS ?= -fno-keep-inline-dllexport -D_WIN32_IE=0x0603 -Wno-unused-local-typedefs -Wno-deprecated-declarations
 +
 +
  CXXFLAGS ?= -fno-keep-inline-dllexport -D_WIN32_IE=0x0603 -Wno-unused-local-typedefs -Wno-deprecated-declarations

Latest revision as of 15:30, 16 November 2023

These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.

The same instructions are valid for newer versions of wxWidgets, just replace 2.8.12 with the version you are using (p.e. 3.2.3).

Installing MinGW

Directions to install MinGW for Code::Blocks can be found here. MinGW installation

Installing the wxWidgets Source Code

The wxWidgets 2.8.12 distribution can be found at the wxWidgets download site. (Note that there is also a winhelp file available.) You can choose between an installer and a zip file. You can just get the zip file because the installer is also a zipped version.

If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly.

NOTE: For the remainder of these instructions we call the wxWidgets directory <WXWIN>. You have to change it to your corresponding directory (e.g. "C:\wxMSW-2.8.12\wxMSW-2.8.12" or "C:\wxWidgets-2.8.12\wxWidgets-2.8.12").

NOTE: You do not need MSYS. Furthermore, you cannot have MSYS in your path, or the wxWidgets compilation will fail. Thus, if you have MSYS installed, ensure that <MSYS>\bin is not in your path before compiling wxWidgets. wxWidgets must be compiled from a "regular" command line (like cmd.exe), not from a Unix-like shell. The same problem could arise if Cygwin is in the path.

NOTE: For the remainder of these instructions we call the MinGW directory <MINGW>. You have to change it to your corresponding directory (e.g. "C:\MinGW").

NOTE: If you intend to compile C::B itself with this wxWidgets version then you must edit <WXWIN>\include\wx\msw\setup_0.h (or setup.h if the former does not exist), locate the line defining wxUSE_GRAPHICS_DIRECT2D and change the assigned value to 1. Do not start compilation before changing this or you will waste a lot of time fixing this.

Checking make Version

If you didn't install MinGW yourself you have to ensure you are using a recent enough version of the make utility. Open a command prompt and type:

cd /D <MINGW>\bin
mingw32-make -v

The version should read 3.80 or higher.

NOTE: the /D flag after cd may be omitted from all commands; it simply allows command prompt to change drives if necessary.

Building wxWidgets

To compile wxWidgets, open the command prompt window and change to the wxWidgets directory:

cd /D <WXWIN>\build\msw
SET PATH=<MINGW>\bin;<MINGW>\mingw32\bin

NOTE: This is normally SET PATH=C:\MingGW\bin;C:\MingGW\mingw32\bin

Now clean up the source:

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release clean

NOTE: Make sure you use exactly the same options for this step and for the build step below. The clean target uses these variables and only cleans the specified version of the generated object and library files. (It will not clean the intended files if these variables are not identical.)

NOTE: If you still have problems with compiling after cleaning, you could try to manually remove the gcc_msw directory under the build\msw directory. This directory is the place where the object files are stored.

When everything is clean you can start compiling wxWidgets:

mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release

NOTE: These options are the officially-supported Code::Blocks options. If you want another version of wxWidgets (debug or non-Unicode) you still have to make sure you build a MONOLITHIC version (one big DLL) for building Code::Blocks.

Patience. This step takes time. Make sure there was no compilation error before you continue.

Errors while building wxWidgets

Navigate to the folder build/msw inside wxWidgets directory. In this folder is a text file named config.gcc which you can edit with notepad to control the build options. There are two lines to note, CFLAGS ?= and CXXFLAGS ?=. The options given here will go in either or both of those lines.

If your linker runs out of memory while building use:

-fno-keep-inline-dllexport

If your compiler errors out, usually referencing monotree.dll or similar:

-D_WIN32_IE=0x0603

To silence warnings that can significantly slow down the compilation process:

-Wno-unused-local-typedefs

and

-Wno-deprecated-declarations

All of these options apply to both CFLAGS and CXXFLAGS so the two lines containing all the options would look like this:

 CFLAGS ?= -fno-keep-inline-dllexport -D_WIN32_IE=0x0603 -Wno-unused-local-typedefs -Wno-deprecated-declarations
 CXXFLAGS ?= -fno-keep-inline-dllexport -D_WIN32_IE=0x0603 -Wno-unused-local-typedefs -Wno-deprecated-declarations