wxFormBuilder with wxWidgets v3.1.307 December 2019
This is an update of the 2014 article on wxFormBuilder & wxWidgets that makes use of the currently-latest
e26a4f58e495(6 December 2019) snapshot of wxFormBuilder, together with the v3.1.3 release of wxWidgets. Back five years ago my usage of wxFormBuilder did not go far beyond experimentation, which consisted mainly of working out how to package up and embed resources, but starting with wxLED I now use it for a large portion of GUI work even in cases where I end up using code rather than resource files. The major change in how wxFormBuilder is built in this article is avoiding the need for
LD_LIBRARY_PATHto fix up library paths.
Building wxWidgets v3.1.3For production binaries that I will be keeping around my preference is to statically link in libraries that are not system default ones, but at several megabytes a pop this is not always the best thing to do. As a result I build both static and shared versions of wxWidgets — I could extend this to debug builds as well, but so far debug builds are only really of use debugging wxWidgets itself rather than programs that use it.
tar -tjvf wxWidgets-3.1.3.tar.bz2 cd wxWidgets-3.1.3 mkdir buildshared cd buildshared ../configure --prefix=/opt/wxWidgets-3.1.3/shared --enable-monolithic make && make install
tar -tjvf wxWidgets-3.1.3.tar.bz2 cd wxWidgets-3.1.3 mkdir buildstatic cd buildstatic ../configure --prefix=/opt/wxWidgets-3.1.3/static --disable-shared make && make install
Other build optionsI personally prefer to add the
--enable-monolithicparameter to the configure script as it greatly reduces the number of seperate library files. Other parameters of interest are
--enable-debugto create a build with debug symbol and
--with-x11to use a back-end other than GTK. Note that the Motif and X11 backends have missing functionality such as
SetDataObject. At time of writing some combinations of build parameters, such as
--with-x11 --enable-monolithicresult in a failing build.
Building & installing wxFormBuilderAt time of writing the last tagged release is v3.9.0 which came out in October 2018, so there is not much choice other than to use the latest snapshot and work backwards if anything major does not work. The normal build procedure is bypassed in order to pass in a
--rpathparameter that builds the non-standard location of wxWidgets into the binary and hence negating the need for
LD_LIBRARY_PATH. It may be possible to use the normal install routines but I decided that manually copying the compiled files was less likley to cause complications. It looks like some debug messages are enabled even in release mode as
build=releasedoes not suppress them.
git clone --recursive --depth=1 https://github.com/wxFormBuilder/wxFormBuilder cd wxFormBuilder export PATH=/opt/wxWidgets-3.1.3/shared/bin:$PATH ./create_build_files4.sh --rpath=/opt/wxWidgets-3.1.3/shared/lib cd build/3.1/gmake/ make build=release cd ../../../output mkdir /opt/wxFormBuilder cp -r * /opt/wxFormBuilder cd /opt/wxFormBuilder/share rm wxformbuilder ln -s .. wxformbuilder
Once this is done running
/opt/wxFormBuilder/bin/wxformbuilder-31 should start wxFormBuilder.
Problem with static buildsWhile wxFormBuilder is precisely the type of program I would want to link wxWidgets into statically, it unfortunately is still broken resulting in the error below. Adding
-fPICto the build parameters is notionally simple enough, but in the past such “simple” changes have been complicated by either the build system plumbing not picking them up, or the change breaking someone else down the line. As a result I decided not to investigate.
==== Building additional-components-plugin (debug) ==== Creating ../../../output/lib/wxformbuilder Creating obj/Debug/additional-components-plugin additional.cpp Linking additional-components-plugin /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/../../../../x86_64-slackware-linux/bin/ld: /opt/wxWidgets-3.1.3/static/lib/libwx_gtk2u-3.1.a(monolib_appbase.o): relocation R_X86_64_32S against `_ZTV18wxConsoleAppTraits' can not be used when making a shared object; recompile with -fPIC /opt/wxWidgets-3.1.3/static/lib/libwx_gtk2u-3.1.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status additional-components-plugin.make:85: recipe for target '../../../output/lib/wxformbuilder/libadditional-31.so' failed make: *** [../../../output/lib/wxformbuilder/libadditional-31.so] Error 1 Makefile:28: recipe for target 'additional-components-plugin' failed make: *** [additional-components-plugin] Error 2