Installation

The first thing to know is that if you have CodeLite installed on your system, wx-config is also already installed (the default install path is c:\Program Files\Codelite)

If you don't have it yet, you can download it from here and extract the obtained archive in a PATH accessible folder (you'll probably be able ot find lots of tutorials on internet on how to achieve this).

To test if it is correctly working, just open a Terminal window, type wx-config --v and you should get something like the following :

wx-config-version
wx-config call on Windows

Basic use

As the goal of this utility is to help you compiling wxWidgets application, you must of course have a working wxWidgets installation on your system.

There is at least one parameter you'll have to provide on the command line to make it work properly : the --prefix one. It will allow you to specify the wxWidgets libs installation directory (for example C:\wxWidgets-3.0.3).

With the above example, your command line will start with : wx-config --prefix=C:\wxWidgets-3.0.3.

You can make a first test to see if it works, by entering the following command in a Terminal window : wx-config --prefix=C:\wxWidgets-3.0.3 --version

If it works, it will only output the wxWidgets libs version found like in the following screenshot :

wx-config-wxversion
wx-config giving the wxWidgets version

But if, as I did, you've used the CFG flag when building your libs, you will obtain an error saying that no setup.h file has been found :

wx-config-error1
wx-config giving an error

This error is due to the fact that when you use the CFG flag for building your libs, the resulting libs subfolder doesn't have a standard name (by standard name, I mean something like gcc_lib, gcc_dll, vc_lib, vc_dll).

In this case, you must specify where the setup.h file is placed for your libs. It is generaly in a subfolder of the libs one, named mswu or mswud (depending on debug or release libs).

In my case, I've built wxWidgets-3.0.3 libs for Visual C++ in static mode with a CFG value of 32 (for 32 bits libs). The resulting libs folder is named vc_lib32instead of vc_lib.

So, as said on the screenshot above, we can specify this on the command line using the --wxcfg parameter.

Our command line will become wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswu --version for a release build and wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswud --version for a debug build.

wx-config-wxversion
wx-config giving the wxWidgets version

But getting the wxWidgets version number won't be very usefull (you can use it to check the version if, like me, you have more than one installation of the libs, but that's all).

The first thing you can obtain with wx-config is the list of all compilers flags needed to build an application.

You can get this with the --cxxflags parameter in place of the --version one :

wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswu --cxxflags

wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswud --cxxflags

wx-config-cxxflags
wx-config giving the compiler parameters

There are also 2 other parameters for this, but they can be considered as synonyms of the above because they give the same output.

They are --cflags and --cppflags :

cflags and cppflags
wx-config giving the compiler parameters

The second thing you can obtain with wx-config is the list of all linker flags, with the --libs parameter :

wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswu --libs

wx-config --prefix=C:\wxWidgets-3.0.3 --wxcfg=vc_lib32\mswud --libs

linker flags
wx-config giving the linker parameters

Setting default values

Instead of always specifying the --prefix and --wxcfg parameters, you can define them using the WXWIN and WXCFG environment variables.

These variables can be defined during the Terminal session, or they can be defined system wide (so you don't have to redefine them each time).

To define (or modify) them for the current Terminal session only, just assign them in your terminal like in the following screenshot (keep in mind that you'll have to redefine them if you close the window) :

default values
setting default values

To define them system wide so you won't have to redefine them each time you need them, you can have a look at this page.

The method is the same : the only difference is that you don't want to modify a system variable, but you want to add a new one.

More about wx-config

There are more things you can get with this utility.

To have a look at all the possibilities it gives, just type wx-config --help in your Terminal.

Usage: wx-config [options]
Options:
--prefix[=DIR]              Path of the wxWidgets installation (ie. C:/wxWidgets2.6.3)
--wxcfg[=DIR]               Relative path of the build.cfg file (ie. gcc_dll/mswud)
--cflags                    Outputs all pre-processor and compiler flags.
--cxxflags                  Same as --cflags but for C++.
--rcflags                   Outputs all resource compiler flags. [UNTESTED]
--libs                      Outputs all linker flags.

--debug[=yes|no]            Uses a debug configuration if found.
--unicode[=yes|no]          Uses an unicode configuration if found.
--static[=yes|no]           Uses a static configuration if found.
--universal[=yes|no]        Uses an universal configuration if found.
--compiler[=gcc,dmc,vc]     Selects the compiler.
--release                   Outputs the wxWidgets     release number.
--version                   Outputs the wxWidgets version.
--basename                  Outputs the base name of the wxWidgets libraries.
--cc                        Outputs the name of the C compiler.
--cxx                       Outputs the name of the C++ compiler.
--ld                        Outputs the linker command.
-v                          Outputs the revision of wx-config.

Note that using --prefix is not needed if you have defined the
environmental variable WXWIN.

Also note that using --wxcfg is not needed if you have defined the
environmental variable WXCFG.

I will try to find the time, in the future, to improve this article to give you more details on these possibilities.

Waiting for that, if you have any question, requirements or simples remarks, don't hesitate to contact me.