Search code examples
c++mingwwxwidgetsubuntu-16.04

Handling multiple compilations of wxWidgets


I am planning to develop a small scale gui application using wxWidgets on Ubuntu 16.10. I have downloaded the source package of version 3.1.0 and I am able to build the package succesfully for the native platform and for Windows with MinGW.

However, the problem is that I could not figure out what prefixes I should pass to the ../configure --prefix= command.

If I do not pass anything for prefixes and then install both of them using make install, 2nd one overrides the 1st one. Although wx-config shows the other configuration as "Also found in /usr/local...", I am not able to select it using --toolkit=gtk2 option, wx-config says that there is no such build.

So basically, what should be the prefixes for each build according to linux naming rules and wxWidgets conventions in general?

Note: builds are: gtk2-unicode-static-3.1 and x86_64-w64-mingw32-msw-unicode-static-3.1


Solution

  • In principle, wx-config is definitely supposed to be able to select between multiple builds of the same library (this is about 90% of its entire logic and purpose in life), but I'm afraid there might be a problem with wx-config logic for the build selection and --host option, which would be needed to select the right build in your case.

    I'm not sure myself because I actually never use wx-config to select between multiple builds and instead simply never install them at all and use the script from the build directory. I.e. what I'm certain does work is:

    $ mkdir -p ~/build/wx/gtk
    $ cd $_
    $ ~/src/wx/configure # of course, you can add other options, if needed
    $ make -s
    $ mkdir ../msw
    $ cd $_
    $ ~/src/wx/configure --host=x86_64-w64-mingw32 --with-msw
    $ make -s
    $ cd ~/src/my/program
    $ make WX_CONFIG=~/build/wx/gtk/wx-config # or the MSW one
    

    Using a wxWidgets build without installing it like this does waste some disk space (you can do rm *.o to reclaim most of it, of course -- just don't do make clean which would erase the libraries too), but otherwise it has only advantages:

    1. You don't need any special rights which are typically required to write to /usr/local or wherever.
    2. You can easily have as many builds as you need and choosing between them is explicit by just selecting the right wx-config.
    3. If anything goes wrong, you can just rm -rf ~/build/wx/whatever at any moment and start anew.