Personal tools
You are here: Home cmgui Wiki Building Cmgui with wxWidgets
Views
Cmgui from source >>

Building Cmgui with wxWidgets

last edited 2 months ago by pbier

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/pbie003/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/pbie003/cmiss/wxWidgets
  make clean
  make
  make install

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/pbie003/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/pbie003/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.

Contributing to this site

Please add to the wiki any relevant information that you think might be useful to other users of this website. For example, you might like to contribute your experiences, questions and answers.

You are encouraged to contribute to this site regardless of your level of experience. Contributions are welcomed from new and regular visitors.

If you ask a question and receive an answer from a developer you should record it in the wiki. This information is extremely useful and can help other users overcome the same problem.

See how to add and edit pages for more information.