Compiling wxWidgets

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Compiling wxWidgets

Post by ermano »

After 3 days of doing nothing else than trying to compile wxWidgets under Windows I'm at the point of giving up or throwing the computer out of the window.
The hardware is a Win7 Dell Optiplex, 8GB of memory, 64 bit.
I already had wxWidgets-2.8 running in combination with Codeblocks 10.05 and the mingw compiler that came with it (V. 4.41).
(Using only the 32Bit-versions in all compilers mentioned hereafter)
The trouble started whith the idea to move to wxWidgets-3.0

Here is my suffering after three days of trying to get it to go:
Installing wxWidgets-3.0 and trying to compile it with the gcc V.4.4.1:
mingw32-make -j -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport 2>_Error.log
in "C:\wxWidgets-3.0.0\build\msw" => The compilation seemed to be doing ok but no ud.a / u.a where created
All different combinations: (SHARED= 0;, debug, MONOLITHIC= 0 without "CXXFLAGS=-fno-keep-inline-dllexport clean 2>_Error.log
in "C:\wxWidgets-3.0.0\build\msw" => The compilation seemed to be doing ok but again no ud.a / u.a where created"
Also tried adding "SHELL=CMD.exe" -> no success

I did make sure that the PATH variable was set to the mingw/bin directory and I removed all possibly conflicting applications (AVR-compiler, MSYS etc) - to the point that I only left "....mingw/bin" in the PATH variable - no success

I did a "clean" before and after trying to go from "release" to "debug" - no success
I de- and re-installed the corresponding wxWidgets version whenever I went for a new Flag combination - No success

In my despair I wanted to go back to wxWidgets2.8 (which I stupidly erased in the meantime) and could not compile this one anymore either !

After that I updated to the latest mingw compiler (4.8.1) (and changed the Path varaible accordingly) -> still unable to compile neither 2.8 nor 3.0
Than I Installed TDM-GCC-32 (and changed the Path varaible accordingly) -> still unable to compile neither 2.8 nor 3.0

All wxWidgets versions (tried also 2.9) where downloaded from the official wxWidgets website

I tried other suggestions as: http://forums.wxwidgets.org/viewtopic.php?f=19&t=27900 and installed MSYS (and added the folder to the path) -> Different error messages but still no success.
In the past I could however compile wxWidgets on my laptop (16GB, Windows8) as well as on a different computer (Windows7 4GB memory) in UNICODE/SHARED/MONOLITHIC = 1 - settings so it must be possible !!

I even tried to go back to a system anchor point a week ago (so before the whole mess started) -> in vain

Here are the latest error messages:
A) MSYS, wx3.0: (UNICODE/MONOLITHIC : enabled, SHARED: disabled, debug enabled)
loads of "fatal error" messages in config.log like:
configure:32889: g++ -c conftest.cpp >&5
conftest.cpp:76:19: fatal error: netdb.h: No such file or directory...


B) wx3.0 in from CMD Window: mingw32-make -j -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport clean 2>_Error.log
-----------------------------------------------
Her e come the content of _Error.log:
The system cannot find the path specified.
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
from ../../src/regex/regcustom.h:39,
from ../../src/regex/regguts.h:38,
from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:189:22: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h"
^
compilation terminated.
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1
-----------------------------------------------------------------------------

Sorry for this long post put I had to get rid of my frustration:

ermano
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Re: Compiling wxWidgets

Post by ermano »

Oups,

forgotten to tell: The first wx-3.0 compilation did actually work and I could compile and link it with the program written in CodeBlocks.
Launching the compiled program(s) did however lead to a straight crash which brought me to a second attempt of compiling wx-3 and the
subsequent mess I just described...
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling wxWidgets

Post by doublemax »

I usually use VisualStudio only, so i can't really help with Mingw related problems.

But as so many people seem to have problems with this, i just tried it myself:

Clean Windows XP 32 bit in a virtual machine.

Downloaded:
http://sourceforge.net/projects/tdm-gcc ... e/download
http://sourceforge.net/projects/wxwindo ... p/download

Run tdm-gcc installer, left all settings at default.
Reboot after install.

Unpacked wxWidgets-3.0.0.zip to c:\wxWidgets-3.0.0\
Open command window.
Navigate to c:\wxWidgets-3.0.0\build\msw\

Entered this command.
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug

Compilation took around 30 mins, but completed without errors.
Use the source, Luke!
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Re: Compiling wxWidgets

Post by ermano »

Thanks for your prompt reply,
as far as I can see you did exactly the same as I did...
The strange thing is that it worked once (when I originally compiled wx2.8 something like a year ago).
I had this issue on other computers as well - that it worked at the beginning but re-compiling it (to change some of the options or for a newer version) killed it.
-As if some parameters were changed/set once deep down in the system which make it a one-off run.

Thanks nevertheless, I'm off now for a couple of days but will check the forum from time to time,

regards and merry X-mas: Hermann
winvdk
Knows some wx things
Knows some wx things
Posts: 29
Joined: Fri Jun 01, 2012 1:30 am
Location: Taiwan

Re: Compiling wxWidgets

Post by winvdk »

I do feel your frustration. Below is distilled from my notebook. It records how wxMSW 3.0.0 was built last time in my computer. I'm not an expert and can't guarantee it will work in your condition.

1. Install TDM-GCC 4.8.1

2. Go download mingw-get-setup.exe. Double click it and only select "msys-base". After the installation, double-clicking C:\MinGW\msys\1.0\msys.bat will enter the MSYS shell. Create a shortcut on the desktop or in start menu, if you want.

3. Edit C:\MinGW\msys\1.0\etc\fstab so as to add a mount point "/usr/local" in MSYS shell. For example,

Code: Select all

Z:\posix_usr_local /usr/local
will have MSYS treat "Z:\posix_usr_local" as "/usr/local".

4. Enter MSYS. It will automatically creae a folder "C:\MinGW\msys\1.0\home\YourAccountName\", or you can create the folder yourself. Add a file named ".bashrc" there. The contents is

Code: Select all

export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib
5. Reenter MSYS and execute the following commands.

Code: Select all

tar --extract --bzip2 --file wxWidgets-3.0.0.tar.bz2

cd wxWidgets-3.0.0/

sed --in-place 's/^CPPFLAGS ?= /CPPFLAGS ?= -fno-keep-inline-dllexport/' build/msw/config.gcc

sed --in-place 's/^\(# \+elif defined(__GNUC__)\) && !wxCHECK_GCC_VERSION(4, 5)$/\1/' include/wx/dlimpexp.h

mkdir build_mswu/

cd build_mswu/

../configure --prefix=/usr/local --enable-official_build --enable-unicode # For more information, please see "../configure --help"

make COMPILER_VERSION='' install
See http://forums.wxwidgets.org/viewtopic.php?f=23&t=38509 to understand why we need "sed" here. Thanks to Eran.

That's it. The headers and .dll files are all be placed in "Z:\posix_usr_local\". To build a wx application in MSYS

Code: Select all

g++ myapp.cpp $(wx-config --cxxflags --libs core,base)
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling wxWidgets

Post by doublemax »

As if some parameters were changed/set once deep down in the system which make it a one-off run.
I doubt that. It's more likely something in the source tree. So instead of just make "clean", try deleting the whole source tree and get a fresh one.
Use the source, Luke!
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Re: Compiling wxWidgets

Post by ermano »

What I did each time was a full-blown de/re-installation of the corresponding wxWidgets package after each attempt.
This should have restored the correct tree !?

Also thanks to Winvdk for his help, I'm off (and exhausted) now, I will give it a new try in 2014.

Hermann
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Compiling wxWidgets

Post by xaviou »

Hi
ermano wrote: B) wx3.0 in from CMD Window: mingw32-make -j -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport clean 2>_Error.log
-----------------------------------------------
Her e come the content of _Error.log:
The system cannot find the path specified.
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
from ../../src/regex/regcustom.h:39,
from ../../src/regex/regguts.h:38,
from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:189:22: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h"
^
compilation terminated.
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1
-----------------------------------------------------------------------------
I think the problem comes from the "-j" option.

If you want to use "multi-jobs" build, you'll have to do it in 2 steps :
First, launch your command line without the "-j" option, but add the "setup-h" target :

Code: Select all

mingw32-make  -f makefile.gcc setup_h BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport
Then, launch your multi-jobs build command line :

Code: Select all

mingw32-make  -j -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport
It should work as expected.

You should also specify the number of jobs you want to use, because if the "-j" option is given without the number of jobs, "infinite jobs will be used".
For example :

Code: Select all

mingw32-make  -j 4 -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport
Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Re: Compiling wxWidgets

Post by ermano »

Bonjour Xavier - et merci d'avoir répondu à mon "blème" (apparemment tu vis juste à coté de moi)...

To come back t the problem: I'm relatively sure that I also tried without the -j option, but admittedly I'm not 100% certain anymore given the feeling to have tried everything.
As told, I'm off now for a couple of days but I will give it another try once I'm back.

Merry X-mas: ermano
ermano
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Mar 16, 2011 9:26 am
Location: Grenoble, France

Re: Compiling wxWidgets

Post by ermano »

After all it worked out, but for reasons that are still not quite clear to me...
After my holiday I just switched on the computer, typed in "mingw32-make -j4 -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 CXXFLAGS=-fno-keep-inline-dllexport 2>_Error.log" and off it went without moaning.
(Same for debug). The only two explanations I can come up with are:

a) Simply the reboot
b) Changing the -j to -j4 option as suggested by Xavier (although I still have the feeling that I did this during the course of events).

Thanks for all the constructive comments - very appreciated indeed !

Hermann
RokitanskyAscoff
In need of some credit
In need of some credit
Posts: 1
Joined: Sat May 20, 2017 10:48 am

Re: Compiling wxWidgets

Post by RokitanskyAscoff »

Have ran into the issue of:

..\..\include/wx/platform.h:...: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h""

and thought I would post for future google hits..

As xaviou suggested, in my case this problem was related to multiple jobs. I think one of the subsequent jobs tries to access wx/setup.h before it is copied in another job.

So what I do to build wxWidgets 3.1 using mingw64: (using makefile from windows cmd)

mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" --jobs=1

I let this run for a few seconds and then kill it with Ctrl-C, then:

mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" --jobs=8
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Compiling wxWidgets

Post by PB »

To prevent any misinformation: While the procedure described RokitanskyAscoff works, it is not the ideal solution. What you need to do when using parallel builds is to build setup_h target first, see. e.g. the code in my answer here.

This solution has been recently finally added to the official documentation.
Post Reply