Root with win32gcc and MinGW

Dear All,

I am trying to compile rootv4.04.02f with mingw (I’m using the option -mno-cygwin for gcc, g++, f77 and the linker in the makefile root/config/Makefile.win32gcc).

I get the following error message:

gcc -mno-cygwin -I/include/ -g -pipe -Wall -D_DLL -Iinclude -DG__REGEXP -DG__UN
IX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__CYGWIN -DG__NEWSTDH
EADER -o cint/src/auxu.o -c cint/src/auxu.c
In file included from include/common.h:50,
from cint/src/auxu.c:21:
include/G__ci.h:503:19: regex.h: No such file or directory
cint/src/auxu.c: In function G__matchregex': cint/src/auxu.c:676: error:regex_t’ undeclared (first use in this function)
cint/src/auxu.c:676: error: (Each undeclared identifier is reported only once
cint/src/auxu.c:676: error: for each function it appears in.)
cint/src/auxu.c:676: error: parse error before "re"
cint/src/auxu.c:678: warning: implicit declaration of function regcomp' cint/src/auxu.c:678: error:re’ undeclared (first use in this function)
cint/src/auxu.c:678: error: REG_EXTENDED' undeclared (first use in this functio n) cint/src/auxu.c:678: error:REG_NOSUB’ undeclared (first use in this function)
cint/src/auxu.c:680: warning: implicit declaration of function regexec' cint/src/auxu.c:680: error:regmatch_t’ undeclared (first use in this function)
cint/src/auxu.c:680: error: parse error before ‘)’ token
cint/src/auxu.c:681: warning: implicit declaration of function `regfree’
make: *** [cint/src/auxu.o] Error 1

Has anybody already succeded in what I’m trying to do? Any suggestion is welcome.

Thanks.

Claudia

Hi Claudia,
you’d have to port it properly - i.e. take care of the compiler and linker flags (which is probably easy), and hack your way through the API which is not provided by wingw. That’s the difficult part. “regex.h” missing might mean that you didn’t install some cygwin package - or that this function is simply not available in mingw’s glib/newlib implementation. It might be worth the effort, though; right now mingw is a lot faster than pure cygwin.
Axel.

Hi Axel,

thanks four your reply. I’m really a beginner with this.

I already managed to compile the same root version with cygwin, so everything needed by root is there for cygwin. What can I do if some headers are not available for mingw?

Could you explain me what you mean by “hack your way through the API which is not provided by wingw”? as I said, I’m really a beginner…

Cheers,

Claudia

Hi,

a header might not be there because
a) you forgot to install a package that’s needed, or
b) the package of the functions in that header just don’t exist.

cygwin and mingw try to re-implement all functions known from linux (like fopen etc), and “translate” the into their corresponding windows call (“WinOpenFileEx” or whatever it may be). If reagex.h dowsn’t exist it might well be that mingw hasn’t implemented the functions yet that are usually defined in that header. In other words: there’s no point for mingw in providing that header, if these functions have never been imlpemented by the mingw team. So you’d have to find a way to build root without using regex.h (and whatever else is missing), or implement the functionality yourself (i.e. you’d have to do the mingw guys’ job).

Cheers, Axel.

Hello Claudia, Hello Axel,

I’ve started an effort to make MinGW compile Root. Unfortunately my knowledge of the Root build system is very limited, so in order to properly integrate everything, somebody of the Root core members should have a look. So far I have made the target ‘rootlibs’ work. In doing so I didn’t take care of the build system, I just daffed aside all compilation/linking hurdles…

The following is a step by step description (though not in perfect detail) of how I built the root libraries (make target ‘rootlibs’) with MinGW. Note: on my system Cygwin is not installed.

  1. install mingw-3.1.0-1 to c:\mingw
  2. install msys-1.0.10 to c:\msys

I found that the regular expression functionality is missing under MinGW. So I built it with MingW from source (without problems):
3) build regex-0.12 from source

  • cp dlfcn.h /c/mingw/include
  • cp libregex.a /c/mingw/lib

I need freetype for my purpose but couldn’t make the builtin version work, probably because of problems with the build system…
4) built freetype-2.1.9 from source

  • ‘make install’ should install to c/msys/local/(bin|include/freetype2|lib)
  • additionally cp ftbuild2.h c/msys/local/include/freetype2 (this is necessary, if I remember correctly)

Copy the Root files I’ve modified (get it from here) over your root v5.04.00 sources:
5) cp -r root-5.04.00-mingw root-5.04.00

I had problems building the ‘afterimage’ library with MinGW, so I left it away. I simply changed the ‘win32gcc’ architecture to my needs. In fact it is a melange between ‘win32gcc’ and ‘win32’. (By the way: what exactly is the difference between ‘architecture’ and ‘platform’? Trying to understand the logic behind the build system these terms confused me.) Hence the configure statement looks like this:
6) configure win32gcc --disable-builtin-freetype --disable-builtin-afterimage --disable-asimage

  1. make rootlibs

Kind Regards,
Andreas Schömann

Hi Andreas,
very good! Did you build with X11 or using the native windows API? I assume it’s the latter, since you don’t have cygwin installed, correct? Did you build all the win modules? MingW is not linux, so you should not define linux in your makefile. Instead it should be a proper windows build, using the windows API, where MS’s compiler and linker are replaced by GCC. If you indeed have all of that please send me a diff, so I can have a look at it!
Axel.

No X11. My approach was as follows: I started with the ‘Makefile.win32gcc’, added compiler and linker flags from ‘Makefile.win32’, and changed this and that (what seemed to be reasonable in my eyes). Then I excluded the check for X11 from the ‘configure’ script. After that I changed the included modules in the main ‘Makefile’. I had the choice between ‘architectures’ (again my question: what is the difference between the terms ‘architecture’ and ‘platform’?) ‘win32’, ‘win32gcc’ and unix. ‘win32’ includes the modules ‘winnt’ and ‘win32gdk’ (so this is not for native win32 api!?) which made sense to me, so I chose it but renamed it to ‘win32gcc’. Later I found that module ‘win32gdk’ did not build (I got hundreds of warnings, even errors) so I exluded it from the build. As I understand it, this means there is no graphic interface now. Do I have to include module ‘win32’, which looks like the native win32 interface, instead? But anyway, this doesn’t bother me much as my goal is to build a cross-platform graphic interface with FLTK similiar to Qt. In fact, some of this is already working…

As said I’ve included ‘winnt’. Is there anything else besides ‘win32’?

Yes, that is what I’m trying to do (except for my FLTK plans, but that is independent from the native win32 interface.) The ‘Makefile.win32gcc’ still has PLATFORM=linux. If I remember correctly, trying to change this into ‘win32’ broke the build because win32 has totally different compile and linker scripts - /build/unix vs. /build/win.

As mentioned in the step by step description above, you can get all my modifications from andreas-schoemann.de/root-mingw

Kind Regards,
Andreas Schömann

I’ve tried to build module ‘win32’ with gcc - that fails. The switch from MSVC to GCC produces multiple warnings and errors.

Kind Regards,
Andreas Schömann