Skip to content

build_windows_mingw64

bluehazzard edited this page Jun 4, 2019 · 4 revisions

Building codeblocks on windows with mingw64

Required downloads:

Mingw64:

wxWidgets:

Codeblocks soure code:

Codeblocks nightly build or release

  • Download a nightly build or a release version from the official codeblocks side and install it (for nightly you simply have to extract it)

Prepare the environemnt

  • Open a cmd window by pressing the Windows Key+R on the keyboard. In the opening window you enter cmd and press enter
  • In the opening black window you type set PATH=%PATH%;pathToCompilerBindFolder where you have to replace pathToCompilerBindFolder with the path to the bin folder of your installed compiler. For example if you have installed mingw64 to C:\mingw64 then the command will look like this: set PATH=%PATH%;C:\mingw64 press enter. You can check if everything worked by typing echo %PATH% and pressing enter. There should be shown a lot paths and at the end there should be the path to your compiler.
  • Go to the extraction direcotry of the wxWidgets source code by using the cd command. For example if you have extracted wxWidgets to g:\wxWidgets then type cd g:\wxWidgets\build\msw

Building wxWidgets

  • You should be in the msw build folder of wxWidgets. Now you can build wxWidgets by typing: mingw32-make.exe -fmakefile.gcc BUILD=debug MONOLTIHIC=1 SHARED=1 and pressing enter. This can take quite some time to finish. Go drink a coffee :). If you have a multicore machine you can add -jn where n is the number of your cores to speed up the process. So if you have 4 cpu cores the command line should be: mingw32-make.exe -j4 -fmakefile.gcc BUILD=debug MONOLTIHIC=1 SHARED=1 NOTE: this will build the debug version of wxWidgets. It takes some more space, but allows to give good feedback to the forum.

Building wxWidgets trunk

  • If you want to build the latest wxWidgets trunk: Download the source from github by making a swallow clone: git clone --depth 1 https://github.com/wxWidgets/wxWidgets.git
  • init submodules: git submodule update --init
  • copy the file include/wx/msw/setup0.h to include/wx/msw/setup.h
  • You should be in the msw build folder of wxWidgets.
  • we build wxWidgets in two steps by typing:
  1. mingw32-make.exe -fmakefile.gcc BUILD=debug MONOLTIHIC=1 SHARED=1 setup_h and pressing enter and then
  2. mingw32-make.exe -fmakefile.gcc BUILD=debug MONOLTIHIC=1 SHARED=1 and again enter. This can take quite some time to finish. Go drink a coffee :). If you have a multicore machine you can add -jn where n is the number of your cores to speed up the process. So if you have 4 cpu cores the command line should be: mingw32-make.exe -j4 -fmakefile.gcc BUILD=debug MONOLTIHIC=1 SHARED=1 NOTE: this will build the debug version of wxWidgets. It takes some more space, but allows to give good feedback to the forum.

Setup Codeblocks

Setup a new compiler

First we have to add our new compiler to codeblocks

  • Start codeblocks
  • Settings->Compiler
  • Select GNU GCC Compiler from the drop down
  • Hit copy -> Enter GNU GCC Compiler mingw648 -> Ok -> Ok
  • In the tabs go to Toolchain executables you probably have to use the right arrow button to make all tabs visible
  • in Compiler's installation directory enter the path to your compiler installation (C:\mingw64 in your top example)
  • In Program Files: fill in the right names for example for C Compiler: x86_64-w64-mingw32-gcc.exe
  • Close the dialog with OK

Load the codeblocks workspace

  • Open the CodeBlocks_wx31_64.workspace file
  • Now a dialog about global variables will open (if not you can open it with Settings->Global Variables)
    • In the list on the left select cb_release_type -> in the middle enter -g in the base field
    • In the list on the left select wx31_64 -> enter the path to the wxWidgets installation (g:\wxWidgets in our case)
    • Close the dialog
  • Now we have to change the compiler of the workspace, because codeblocks expects the default GNU GCC Compiler but we use the GNU GCC Compiler mingw648
  • Open the Project option manipulator plugin: Plugins->Project Options manipulator
    • Scan within: workspace
    • Replace compiler
    • Option/Var -> hit the ... button and select GNU GCC Compiler
    • Replace with -> hit the ... button and select GNU GCC Compiler mingw648
    • Ok
    • Save the projects
  • Because we use the debug build of wxWidgets we have to change the configuration of Codeblocks again with the Plugins->Project Options manipulator plugin:
    • Scan within: workspace
    • Change option
    • Option/Var -> WX_SUFFIX
    • Scope: Custom Var -> ud
    • Ok
    • Save the projects
  • Now start compiling with Build->Build workspace