An Internationalized Software Project With Auto Tools
Prev wxWidgets Overview Next

wxWidgets Overview

So far writing console software was discussed. These programs may be ported to windows as well. A windows gettext port exsists, which allows to write localized software which runs on unix/linux and windows. If gui applications are targeted, a portable gui library is necesary. There are some of them available; here wxWidgets (somtimes called wxWindows) is discussed. wxWidgets has (among other things) the following properties: It should be noted, that just using wxWidgets does not automatically create a portable application, which just has to be compiled on different platforms. There are subtile differences on each platform, so that the application should be compiled and tested regularly on all target platforms!

The first step for adding wxWidgets support is adding some checks for wxWidgets to "configure". Note, that the required autoconf macros have been installed by wxWidgets automatically.

configure.ac

...

# Checks for libraries.

AC_ARG_ENABLE([unicode],[AC_HELP_STRING([--enable-unicode],[internally use unicode])], 
	[AS_IF([test "x$enableval" = "xno"],[wx_config_args="--unicode=no"])
	AS_IF([test "x$enableval" = "xyes"],[wx_config_args="--unicode=yes"])],)
AM_OPTIONS_WXCONFIG

reqwx=2.6.3
AM_PATH_WXCONFIG($reqwx, wxWin=1)
if test "$wxWin" != 1; then
	AC_MSG_ERROR([
		wxWidgets must be installed on your system.
 
		Please check that wx-config is in path, the directory
		where wxWidgets libraries are installed (returned by
		'wx-config --libs' or 'wx-config --static --libs' command)
		is in LD_LIBRARY_PATH or equivalent variable and
		wxWidgets version is $reqwx or above.
		])
fi
 
CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
LIBS="$LIBS $WX_LIBS"

# Checks for header files.

...
A simple make will add all required tests and start them:
# gmake
cd . && aclocal19 -I m4

...

running /usr/local/bin/bash ./configure   --no-create --no-recursion

...

checking for wx-config... no
configure: error:
                wxWidgets must be installed on your system.

                Please check that wx-config is in path, the directory
                where wxWidgets libraries are installed (returned by
                'wx-config --libs' or 'wx-config --static --libs' command)
                is in LD_LIBRARY_PATH or equivalent variable and
                wxWidgets version is 2.4.0 or above.

gmake: *** [config.status] Error 1
In this installation, wx-config is not in the path, so that it has to be provided. "configure --help" shows all "configure" options added by the changes above:
# ./configure --help

...

  --enable-unicode        internally use unicode

Optional Packages:

...

  --with-wxdir=PATH       Use uninstalled version of wxWidgets in PATH
  --with-wx-config=CONFIG wx-config script to use (optional)
  --with-wx-prefix=PREFIX Prefix where wxWidgets is installed (optional)
  --with-wx-exec-prefix=PREFIX
                          Exec prefix where wxWidgets is installed (optional)

...
Most important here is --with-wx-config, which allows to pass the location of the wxWidgets configuration file. It can be called to get the necessary compiler switches. On FreeBSD for example:
# /usr/X11R6/bin/wxgtk2u-2.6-config --version
2.6.3
# /usr/X11R6/bin/wxgtk2u-2.6-config --cflags
-I/usr/X11R6/include/wx-2.6/gtk2-unicode-release-2.6 -I/usr/X11R6/include/wx-2.6 
	-DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DNO_GCC_PRAGMA
# /usr/X11R6/bin/wxgtk2u-2.6-config --libs
-L/usr/X11R6/lib  -pthread -L/usr/local/lib -liconv  -L/usr/X11R6/lib   -lwx_gtk2u_xrc-2.6 
	-lwx_gtk2u_qa-2.6 -lwx_gtk2u_html-2.6 -lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 
	-lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6
To build a non-unicode aware program, wxgtk2-2.6-config should be used instead. On gentoo linux, the program is called wx-config-2.6 and there is just one version for unicode and non-unicode. Here the --unicode switch turns unicode on and off. To pass this switch, configure takes --enable-unicode and --disable-unicode, which should not be used on FreeBSD. If the proper configuration is supplied (here on FreeBSD), "configure" runs through smoothly:
# ./configure --with-wx-config=/usr/X11R6/bin/wxgtk2u-2.6-config

...

checking for wx-config... /usr/X11R6/bin/wxgtk2u-2.6-config
checking for wxWidgets version >= 2.6.3... yes (version 2.6.3)
checking for wxWidgets static library... no

...

The wxWidgets version numbers printed here are the required version as specified with the reqwx line in configure.ac and the actually found version number.

Next the testproj is ported to wxWidgets.
Prev Home Next
Internationalization of the Documentation Using wxWidgets