wx-config is a small command-line utility which can help you while building on unix-like systems (including linux and Mac OS X) It will :
- tell you what compile flags to use (wx-config --cxxflags)
- tell you what link flags to use (wx-config --libs)
- can manage multiple wxWidgets installs with different configurations (wx-config --list et al)
How to use wx-config
Simple use might be something like this:
g++ `wx-config --cxxflags` -o out *.cpp `wx-config --libs`
Of course, if you compile and link your application in separate steps, as is common, you will want to use the --cxxflags bit when compiling to .o and the --libs part when linking them into an executable.
You can even ask wx-config to pick a compiler :
`wx-config --cxx --cxxflags` -o out *.cpp `wx-config --libs`
If you have multiple wxWidgets installations in the same prefix (e.g. /usr/local/), you can select the right build with options like :
Type wx-config --help to know all options that are available
Miscellaneous notes :
- From your IDE, you can simply put `wx-config --cxxflags` in compile flags and `wx-config --libs` in link flags
- If your IDE doesn't support backtick execution or some equivalent, here's what to do : #1 complain to whoever wrote your IDE and #2 run these commands without the backticks in a terminal and copy the output manually
- wx-config will be installed to a system-wide directory on make install, however it is not necessary to issue make install in order to use wx-config. Whenever you build wxWidgets, a local wx-config will be created in the build directory. You can then simply get the flags by calling wx-config locally : ./wx-config. This can also help keeping different configurations truly separate and may avoid some conflicts.
- On Unix systems, wx-config may be a symlink to specific wx-config files for various wxWidgets ports/platforms (wxbase-2.5-config, wxgtk-2.5-config, ...).
- There is also a --basename and --release option, which are helpful for write-once Makefiles (using the same makefile across linux and OSX and for different versions of the library like debug/nondebug unicode/non-unicode, gkt/mac).
- wx-config is very useful, but the GIGO principle applies. If you do: `wx-config --libs foobar` you'll get output like -lwx_gtk2u_foobar-3.0. However it doesn't cause a lib with that name magically to be created...
Important note for wx3.0 and later
wx-config --libs now only gives the standard libs. If you want (for example) aui as well, you need to do: `wx-config --libs std,aui` where 'std' outputs the standard libs.
NB. `wx-config --libs aui` will just give only that gui lib e.g. -lwx_gtk2u_aui-3.0.
Alternatively, `wx-config --libs all` returns all available libraries.
Now there is also a c++ wx-config Windows port, which works similar to this wx-config.