Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Apr 11, 2020 5:53 pm

Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by runeight » Mon Apr 20, 2020 6:41 pm

Steps to get a working installation of Code::Blocks 20.03 w/ MinGW 8.1.0 and wxWidgets 3.1.3

I needed to do this for a new project. I had no experience with wxWidgets, but quite a lot with Code::Blocks. For others like me, this might be useful.

I’m running Win 7 Pro.

Downloads needed:

Code Blocks: Download page:
Code Blocks: Release: codeblocks-20.03mingw-setup.exe
wxWidgets: Download page:
wxWidgets: Release: Windows ZIP or Windows 7Z

Code Blocks Installation

Run the Code Blocks installer, accept defaults for everything. Add the path for the MinGW compiler to the Windows PATH environment variable.

If you installed in the default location, the path to add is: C:\Program Files\CodeBlocks\MinGW\bin

If you don't know how to add MinGW to the Windows PATH environment variable:

Windows 10: ... indows-10/
Windows 7: ... windows-7/

Log out and log in again.

Run Code::Blocks and go to Settings -> Global Variables. Create a new global variable named wx and define the base, include and lib fields. Entries should match the location of wxWidgets on your computer. The pic shows the location I chose.

wxWidgets1.png (53.95 KiB) Viewed 683 times

Next setup global search directories by clicking Settings -> Compiler -> Search Directories. Make entries as shown below in the order as shown below:


There are, apparently, two library files missing from this installation:

Libraries Download:
Download: Release:
Or Download: Release: mingw64runtime-v7-git20191109-gcc9-tdm64-1.tar.xz
Unpack and navigate to here: mingw64runtime-v7-git20191109-gcc9-tdm64-1(1).zip\x86_64-w64-mingw32\lib

The libraries should be in the list. Put them here in your installation: C:\Program Files\CodeBlocks\MinGW\lib

Add to linker settings. In CB go to Settings -> Compiler -> Linker Settings -> Add. Enter the two library filenames above.

If you want to be able to debug go to Settings -> Debugger. Click on Default and enter the path to the MinGW debugger. For my installation this is C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe

wxWidgets Installation

Unpack to your location. Mine is C:\wxWidgets-3.1.3\

Open a command prompt and enter: gcc -v

The last line should be gcc version 8.1.0 (x86_64_posix-she-rev0. Built by MinGW-W64 project)

Change directory (cd) to \build\msw\ inside the wxWidgets directory. Again, in my case: C:\wxWidgets-3.1.3\build\msw

Execute the following commands, in order:

mingw32-make -f makefile.gcc SHARED=0 BUILD=debug MONOLITHIC=0
mingw32-make -f makefile.gcc SHARED=0 BUILD=release MONOLITHIC=0

And yes, they do take some time. :D

On successful completion you can build the "minimal" sample.

Change directory to C:\wxWidgets-3.1.3\samples\minimal.

Execute the make to build the wxWidgets libraries:

mingw32-make -f makefile.gcc SHARED=0 BUILD=debug MONOLITHIC=0

The executable "minimal.exe" should be in C:\wxWidgets-3.1.3\samples\minimal\gcc_mswud.

Launch the app. It should run normally.

Open Code::Blocks and start a new project. When it asks for the project type, scroll down to the bottom and select the wxWidgets icon.

Next screen: select wxWidgets 3.1.x
Next screen: give a project name
Next screen: author, but not required
Next screen: select wxFormBuilder and Frame Based
Next screen: enter location for wxWidgets (for me C:\wxWidgets-3.1.3).
Next screen: default should have GNU GCC Complier with compiler and debugger checked. Leave.
Next screen: select Enable Unicode. Leave the rest unchecked.
Next screen: leave features unselected for this test build. Select Finish.

CB will create a project with several files that create the equivalent of minimal.exe.

Compile this in CB. In my situation, the compile took about 20 seconds, so wait for it.

Then run. If all is well the CB minimal app will pop up after a few seconds and be functional.

All of this worked for me in this order without any problems. Please let me know if I've made any errors.

Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by PB » Mon Apr 20, 2020 7:08 pm

I just skimmed through. My 2 cents:
Do not add the mingw to the path. There is no reason to and it can lead to annoying issues.
Do not add wxWidgets build-specific folders (such as lib/gcc_lib/mswud) or files to compiler settings. Those belong to build-target specific options.
In one of the Project Wizard last steps, one should check "Configure Advanced Options" and on the next page check "Use _WXDEBUG..." and switch the application from Console to GUI for both targets. If the application uses other wx libraries, these may be selected in the next step as well.

I would also recommend using the officially supported mingw-based toolchain, i.e., mingw-64. There is no need to download additional libraries or something like that with it.

I have my own C::B + mingw detailed tutorial I wrote some time ago but it needs to be polished a bit before publishing. :(

Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Apr 11, 2020 5:53 pm

Re: Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by runeight » Mon Apr 20, 2020 8:18 pm

Great. Thanks for the additions/changes. Anyone who needs help to get this all working will benefit from the best instruction steps that we have.

And I am awaiting your tutorial. As a wx newbie, it might save me from other errors and blind alleys. :D

In need of some credit
In need of some credit
Posts: 2
Joined: Thu May 14, 2020 7:25 am

Re: Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by HeliosPrime » Thu May 14, 2020 9:06 pm

Hi Folks,
first of all, thanks runeight for your installation and configuration instructions.
It worked fine also with Win10 and it was my first compilation success after a lot of tries. I'm new to code::blocks and wdWidgets and I would like to use the wxSmith because for me as newbee it seems to be easier to use, cause it is integrated in code::blocks.
wxFormBuilder needs to be installed in some way?
When I try to build a new wxWidgets Project using wxSmith I ran directly into this errors:

Code: Select all

-------------- Build: Release in wxTest2 (compiler: GNU GCC Compiler)---------------

windres.exe -IC:\wxWidgets-3.1.3\include -IC:\wxWidgets-3.1.3\lib\gcc_lib\mswu  -J rc -O coff -i C:\msys64\home\arneg\DevWork\C\wxTest2\resource.rc -o obj\Release\resource.res
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -IC:\wxWidgets-3.1.3\include -IC:\wxWidgets-3.1.3\lib\gcc_lib\mswu -IC:\wxWidgets-3.1.3\lib\gcc_lib\mswud -IC:\wxWidgets-3.1.3\include -c C:\msys64\home\arneg\DevWork\C\wxTest2\wxTest2App.cpp -o obj\Release\wxTest2App.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -IC:\wxWidgets-3.1.3\include -IC:\wxWidgets-3.1.3\lib\gcc_lib\mswu -IC:\wxWidgets-3.1.3\lib\gcc_lib\mswud -IC:\wxWidgets-3.1.3\include -c C:\msys64\home\arneg\DevWork\C\wxTest2\wxTest2Main.cpp -o obj\Release\wxTest2Main.o
g++.exe -LC:\wxWidgets-3.1.3\lib\gcc_lib -o bin\Release\wxTest2.exe  obj\Release\wxTest2App.o obj\Release\wxTest2Main.o obj\Release\resource.res -s -mthreads  -lwxmsw31u_core -lwxbase31u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lshlwapi -lversion -loleacc -luxtheme C:\CodeBlocks\MinGW\lib\liboleacc.a C:\CodeBlocks\MinGW\lib\libuxtheme.a -mwindows
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x816): undefined reference to `jpeg_std_error'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x874): undefined reference to `jpeg_destroy_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x8be): undefined reference to `jpeg_CreateDecompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x8d7): undefined reference to `jpeg_read_header'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x979): undefined reference to `jpeg_start_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x9b1): undefined reference to `jpeg_finish_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x9b9): undefined reference to `jpeg_destroy_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0xb74): undefined reference to `jpeg_read_scanlines'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0xd90): undefined reference to `jpeg_finish_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0xd98): undefined reference to `jpeg_destroy_decompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x16e1): undefined reference to `jpeg_std_error'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x188a): undefined reference to `jpeg_destroy_compress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x18b6): undefined reference to `jpeg_CreateCompress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1931): undefined reference to `jpeg_set_defaults'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1a18): undefined reference to `jpeg_set_quality'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1a76): undefined reference to `jpeg_start_compress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1aae): undefined reference to `jpeg_write_scanlines'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1acb): undefined reference to `jpeg_finish_compress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x1ad3): undefined reference to `jpeg_destroy_compress'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.rdata$.refptr.jpeg_resync_to_restart[.refptr.jpeg_resync_to_restart]+0x0): undefined reference to `jpeg_resync_to_restart'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x239): undefined reference to `TIFFClientOpen'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x24c): undefined reference to `TIFFReadDirectory'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x258): undefined reference to `TIFFClose'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x390): undefined reference to `TIFFClientOpen'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x400): undefined reference to `TIFFClientOpen'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x623): undefined reference to `TIFFSetWarningHandler'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x62f): undefined reference to `TIFFSetErrorHandler'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1c47): undefined reference to `TIFFClientOpen'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1c5e): undefined reference to `TIFFSetDirectory'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1df8): undefined reference to `TIFFClose'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1fb2): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1fcc): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1fe3): undefined reference to `TIFFGetFieldDefaulted'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x1ffb): undefined reference to `TIFFGetFieldDefaulted'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x2015): undefined reference to `TIFFGetFieldDefaulted'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x2027): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x2fe8): undefined reference to `_TIFFmalloc'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x308f): undefined reference to `_TIFFfree'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3097): undefined reference to `TIFFClose'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3663): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x36c2): undefined reference to `TIFFReadRGBAImageOriented'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x373e): undefined reference to `_TIFFfree'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3822): undefined reference to `_TIFFfree'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x39d5): undefined reference to `TIFFGetFieldDefaulted'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3a68): undefined reference to `TIFFGetFieldDefaulted'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3b1c): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x3bf6): undefined reference to `TIFFGetField'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x40dd): undefined reference to `TIFFRGBAImageOK'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x40ff): undefined reference to `TIFFScanlineSize'
C:\wxWidgets-3.1.3\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp:(.text+0x4107): undefined reference to `_TIFFmalloc'
Process terminated with status 1 (0 minute(s), 6 second(s))
50 error(s), 0 warning(s) (0 minute(s), 6 second(s))
How can I fix this (in a professional way)?
Thanks in advance and kind regards

Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by PB » Fri May 15, 2020 6:54 am

HeliosPrime wrote:
Thu May 14, 2020 9:06 pm
When I try to build a new wxWidgets Project using wxSmith I ran directly into this errors:
You need to add wxJPEG library, please notice that the order of libraries matters, should look like this
cb-jpeg.png (27.38 KiB) Viewed 340 times

In need of some credit
In need of some credit
Posts: 2
Joined: Thu May 14, 2020 7:25 am

Re: Installation Instructions wxWidgets 3.1.3 + Code Blocks 20.03

Post by HeliosPrime » Fri May 15, 2020 8:04 am

Hello PB,
thanks a lot for your reply.
Yesterday I looked for the libxwjpeg.a and I did not find it. Maybe i did not included all paths
from the C:\wxWidgets-3.1.3 and the Mingw-64 compiler (C:\CodeBlocks\MinGW\bin in my case).
I needed (in my case) also to add
- libwxtiff.a
- libwxmsw31u_core.a
in the Compiler - Linker Settings
and now, YES IT RUNS with wxSmith!!!
Great! Thanks again!!!
Kind regards

Post Reply