Guide: How to compile wxMax with g++ 4.x.x

BlitzMax Forums/Brucey's Modules/Guide: How to compile wxMax with g++ 4.x.x

Noobody(Posted 2012) [#1]
Since I finally got wxMax to compile after a few days of effort, I thought I'd make a quick guide for others experiencing similar problems.

At the end of this post you will find a download containing all the necessary files and a quick step-by-step guide to get wxMax working. The files were generated with g++ 4.6.2 and may not work with older versions. The following guide is provided for completeness in case the files don't work for you.
The files will most likely only work on Windows.


If you compile wxMax with a newer MinGW version, you'll get thousands of linker errors about missing references. This is because the libraries provided with current wxMax distributions have been compiled with an older MinGW version and won't work with newer versions anymore. To fix this, you'll need to do the following steps:

1. Get the wxWidgets 2.8.12 source distribution from here (wxAll -> other formats: zip).
Extract the zip file and then open up wxWidgets-2.8.12/build/msw and edit config.gcc in your preferred text editor.
Then change the following lines:
UNICODE ?= 0 to UNICODE ?= 1
BUILD ?= debug to BUILD ?= release
USE_OPENGL ?= 0 to USE_OPENGL ?= 1

Then open wxWidgets-2.8.12/include/wx/msw/setup0.h and search for wxUSE_GLCANVAS and wxUSE_GRAPHICS_CONTEXT. Change the corresponding lines to:
#define wxUSE_GRAPHICS_CONTEXT 1
#define wxUSE_GLCANVAS 1

Do the same changes to wxWidgets-2.8.12/include/wx/msw/setup.h and wxWidgets-2.8.12/wx/setup_inc.h

Now you're all set! Fire up the MSYS shell (download it here if you don't have it already), use cd to change the directory to wxWidgets-2.8.12/build/msw and then execute the following command:
mingw32-make -f makefile.gcc

Let the build run and finish.

2. Copy all libraries and the mswu folder from wxWidgets-2.8.12/lib/gcc_lib to wx.mod/lib/win32. Overwrite all existing files.

3. Go to your MinGW folder and copy from MinGW/lib the libraries libgdiplus.a, libodb32.a, librpcrt4.a and libwinspool.a to wx.mod/lib/win32 (overwrite existing files)

4. Go to your BMax/lib folder and overwrite the existing .o and .a files with the corresponding files found in MinGW/lib and MinGW/lib/gcc/mingw32/YOURMINGWVERSION

I tested with MinGW 4.5.2 and 4.6.2 and BMax 1.45 and it seems you also need to copy libstdc++.dll.a and libgcc_s.a to the BlitzMax/bin folder (more about this later)

5. Go to your BMax/bin folder and overwrite ar.exe and ld.exe with the corresponding files found in MinGW/bin

6. You're almost set! The only things left are a few fixes to wxMax:
Open up wx.mod/wx.mod/common.bmx, go to line 170 (right after the last ? ) and paste the following line:
Import "-lgcc_s"

Open wx.mod/wxrarinputstream.mod/src/unrar/os.hpp and go to line 65. Replace the line
#include <new.h>
with
#include <new>

Delete wx.max2d and wx.glmax2d. They will not work with the new version of Max2D.

7. Recompile wx.mod with:
bmk makemods -a wx

Let it finish and then test your installation by running one of the samples coming with wxMax (in wx.mod/samples).

Congratulations! Your wxMax installation should now run perfectly with newer versions of MinGW. Now you can also compile widgets in the SVN trunk of wxMax not found in the binary releases, such as wxTreeListCtrl (something I needed).

The two additional libraries (libstdc++.dll.a and libgcc_s.a) were needed in my case to make additional linker errors disappear. I'm not sure whether they're needed in all cases, but they're certainly a requirement for gcc 4.5.2 and 4.6.2

In case you don't want to go through all the hassle, I prepared a compilation of all the needed libraries. Follow the steps in the installation.txt and you should be fine.
Download it here
The packet has been tested with g++ 4.6.2, BlitzMax 1.45, Windows 7 and the latest wxMax version.


Derron(Posted 2012) [#2]
Just tried different ways to reproduce this guide for linux.
Running an Xubuntu based distribution 12.04 64Bit.

While wxWidgets 2.8.12 is stable, most current wxMax from ages ago is for wxWidgets svn2.9.1.
Means - you get "overload of bla"-errors.

Compilation of wxWidgets is possible but you will compile 64bit libraries.
For being useable for wxMax you have to compile 32bit libraries which then add new hassles aka requirements of libgtk2.0-dev:i386 etc - which need pango and so on...

Further problem (I don't know why that happens) - although I compiled the libs as "static" (ages ago with 32bit linux) and they get linked into a BlitzMax-binary of 9mb size. They are not able to get executed now because the libraries are missing.
So - I included the libraries in the binary (static linking) but now they are missing withing the /lib or /lib64 /... directories ...


But for others to try:

within your linux terminal (or ssh session to your linux dev box :D)
$ ./configure --disable-shared --enable-unicode --with-opengl CC='gcc -m32' CXX='g++ -m32'
$ ./make
- the libs you need are in subfolder "lib" (also the "wx"-folder with the needed setup.h) - copy its content into "BlitzMax/mod/wx.mod/lib/linux"

the "with-opengl" flag replaces the need to replace the #define flags in the setup.h.
leaving out "CC='gcc -m32' CXX='g++ -m32'" will produce 64 bit libraries.


If one gets it working (i'm not in the mood trying it for ages now as I'm not needing it next days) - feel free to answer here.
(But remember: its for developing on 64bit with 32bit BlitzMax).


bye
Ron