Personal tools
You are here: Home / cmgui / Wiki / Building Cmgui with wxWidgets
Navigation
Log in


Forgot your password?
 

Building Cmgui with wxWidgets

It is possible to build the wxWidgets version of cmgui using either static or dynamic libraries. If static libraries are used then the libraries are included with the executable. If dynamic libraries are used then a link to them is included in the executable, rather than the actual contents. An executable compiled with a dynamic library is much smaller and dependent on that library being present, whereas a static build results in a stand alone executable.

Here is how to set up a static build version of wxWidgets for development, assuming you already have a development environment set up for motif.

Download the latest version of wxWidgets from http://www.wxwidgets.org/downloads/#latest_stable Click on the wxAll option. Once the file downloads unzip and extract it to a directory somewhere. I suggest naming the directory with the wxWidgets versionnumber , eg wxWidgets-2.8.4. This directory is where the wxWidgets source files will be placed. The libraries can be built in this same directory but it is tidier to set up a new directory for this purpose.

Next make a directory where the static libraries will be built to:

cd $CMISS_ROOT
mkdir wxWidgets

Now you need to build the static libaries for the debug version, specifying the location of the target/install directory using the prefix flag:

cd dir/installed/wxWidgets/to
./configure --enable-debug  --disable-shared --with-opengl --prefix=/home/bob/cmiss/wxWidgets
make
make install

Now build the static libaries for the optimised version, specifying the location of the target directory using the prefix flag:

cd dir/installed/wxWidgets/to
./configure --disable-debug  --enable-optimised --disable-shared --with-opengl --prefix=/home/bob/cmiss/wxWidgets
make clean
make
make install

Note that to build the shared object library of cmgui-wx on a 64bit linux machine the -fPIC flag has to be turned on and this can be done through the configure command as well. Using the configure command provided above the new command which configures wxWidgets with -fPIC will be:

./configure CFLAGS="-fPIC" CXXFLAGS="-fPIC" --disable-debug  --enable-optimised --disable-shared --with-opengl --prefix=/home/bob/cmiss/wxWidgets
By default the makefiles will try and execute the 'wx-config' program to
determine the correct parameters for compiling with your installation of wx widgets. If the wx-config is not installed into your path then you will need to specify where this is. You do so by adding into your 'cmgui/source/developer.Makefile' a line like this:

DEVELOPER_OPTIONS += WX_DIR = /home/bob/cmiss/wxWidgets/bin/

which will override the value of WX_DIR when building cmgui.

I also ended up removing from 'cmgui/source/cmgui.Makefile' the -lXxf86vm option from the line:

USER_INTERFACE_LIB += $(shell pkg-config gtk+-2.0 gthread-2.0 --libs) -lXmu  -lXinerama -lXxf86vm
This is necessary because when running 'wx-config' we are not using all the
flags, we do not want wxWidgets to pull in lots of extra system libraries that it normally uses such as libz and libbz2, instead we want the versions that we have specifically configured in image_libraries. However depending on your system configuration the X flags required are different. A more complicated way to work around this would be to try and parse the output of wx-config to remove the options we don't want, however getting this to work robustly on a diverse range of platforms would take some testing.

Once these two changes were done I could compile both the optimisied and debug versions of cmgui with wxWidgets:

make cmgui-wx
make cmgui-wx-debug

When cmgui is built with dynamic libraries you may need to set the LD_LIBRARY_PATH environmental variable to include your wxWidgets library directory

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/bob/cmiss/wxWidgets-2.8.4/lib

Building wxWidgets on windows in cygwin

  • To compile and link mingw binaries we must ensure the -mno-cygwin switches are passed to the c and c++ compilers and the linker. Here is the line used to configure and build debug wxWidgets2.8.7, for cmiss root at cygdrive/d/cmiss:

    cd /cygdrive/d/cmiss mkdir wxlib cd wxWidgets-2.8.7 mkdir build_debug cd build_debug ../configure --with-msw --enable-debug --enable-debug_gdb --disable-shared --with-opengl --prefix=/cygdrive/d/cmiss/wxWidgets-2.8.7 --with-expat-builtin CXXFLAGS=-mno-cygwin CFLAGS=-mno-cygwin LDFLAGS=-mno-cygwin make make install

(TODO: investigate whether combination of --host=i686-pc-mingw32, --host_alias=i686-pc-mingw32, --build=i686-pc-cygwin can achieve the above effect).

  • As in the previous notes I had to add this line to developer.Makefile to build cmgui:

    DEVELOPER_OPTIONS += WX_DIR=/cygdrive/d/cmiss/wxWidgets-2.8.7/bin/

  • Currently two minor changes needed in cmgui.Makefile to complete build:

    1. wxrc messes up paths unless we change XRCH_PATH to use '..' instead of '$(CMGUI_DEV_ROOT)'
    2. linker fails to find expat: change '-lwxexpat-2.8-i386-mingw32msvc' to '-lwxexpat-2.8'.