Problem setting environment for GMP in msys on Windows

Sisyphus sisyphus1 at optusnet.com.au
Thu Sep 9 11:14:27 CEST 2010


----- Original Message ----- 
From: "muggins senior" <muggins_senior at yahoo.co.uk>

> Now, if I "cd demos" and "make pexpr", I get a lot of compile errors, 
> starting with:
> pexpr.c:59:17: gmp.h: No such file or directory
> then a lot of stuff about implicit declarations etc. -- so it hasn't seen 
> the files it's meant to link with? If I copy gmp.h from the directory 
> above "demos", then the compile errors change to many lines like:
> C:/DOCUME~1/ME3FF5~1.WYN/LOCALS~1/Temp/ccWHUo82.o:pexpr.c:(.text+0x2eb): 
> undefined reference to `__gmpz_init'
>
> My guess is that something is wrong with the environment or the makefile. 
> This is almost certainly not a GMP bug, and I'm willing to learn as much 
> as I need to about Linux maintenance. However, I'm not interested in that 
> for its own sake (not even for my long-term betterment) and I'm not sure 
> where to start: libtools, make, configure, set, setenv, gcc -L, ...??? Any 
> help would be greatly appreciated!
>

I'm not sure how things are supposed to work there, but if, in the generated 
demos/Makefile, you assign:
-I/usr/local/include
 to the CPPFLAGS entry, then gmp.h is found. (/usr/local/include is, of 
course, the location into which 'make install' placed gmp.h. Had you 
specified CPPFLAGS=-I/usr/local/include as an arg when you ran configure, 
then the CPPFLAGS entry in the Makefile may have been filled in correctly 
for you - not sure and I haven't checked).

The problem with the linking seems at first glance to require a rather 
kludgy solution. I expected it could be fixed by setting the LDFLAGS entry 
(in the demos/Makefile) to:
 -L/usr/local/lib -lgmp

If I do that, then running 'make pexpr' generates the following command:

gcc -std=gnu99 -m32 -O2 -pedantic -fomit-frame-pointer -mtune=k8 -march=k8 -mno-cygwin 
 -I/usr/local/include -L/usr/local/lib -lgmp  pexpr.c   -o pexpr

That command still fails with "undefined references" to the various gmp 
symbols, for the simple reason that the command that needs to be run is:

gcc -std=gnu99 -m32 -O2 -pedantic -fomit-frame-pointer -mtune=k8 -march=k8 -mno-cygwin 
 -I/usr/local/include pexpr.c   -o pexpr -L/usr/local/lib -lgmp

(Same args, but the order has been changed.) If you enter that command 
manually, it should happily build pexpr.exe, but of course that's not making 
use of the demos/Makefile.

Again, if you had specified LDFLAGS="-L/usr/local/lib -lgmp" when running 
configure, then the LDFLAGS entry in the demos/Makefile may well have been 
correctly specified for you - but I'm not sure how to *portably* cater for 
the need to re-arrange the order of the args when building demos/pexpr.exe 
and friends. Perhaps someone here knows how to fix that, and cares enough to 
implement the fix :-)

Alternatively, I could be missing something obvious.

Cheers,
Rob



More information about the gmp-bugs mailing list