[Shapelib] compile error on Windows

Jeff McKenna jmckenna at gatewaygeomatics.com
Mon Jul 10 12:55:29 EST 2017


On 2017-07-10 2:33 PM, Even Rouault wrote:
> On lundi 10 juillet 2017 14:12:53 CEST Jeff McKenna wrote:
> 
>  > On 2017-07-10 1:47 PM, Jeff McKenna wrote:
> 
>  > > Hi all,
> 
>  > >
> 
>  > > I am in the process of upgrading from Shapelib 1.3.0 to 1.4.0 on
> 
>  > > Windows; I had no problems using cmake to compile 1.4.0, however I also
> 
>  > > need to compile the utilities from the /contrib directory. As I don't
> 
>  > > see how to use cmake for that directory, I modified 
> /contrib/makefile.vc
> 
>  > >
> 
>  > > and using Visual Studio 2012 I received this error:
> 
>  > > cl /Ox /MD /nologo /I..
> 
>  > >
> 
>  > > /ID:\build\mapserver-buildkit-2012\shapelib-1.4.0\build\install\include
> 
>  > > /ID:\build\mapserver-buildkit-2012\proj-4.9.3\src /D_LITTLE_ENDIAN
> 
>  > > -DPROJ4 /c shpcat.c shpgeo.c
> 
>  > > shpcat.c
> 
>  > > shpgeo.c
> 
>  > > shpgeo.c(898) : error C2065: 'NAN' : undeclared identifier
> 
>  > > shpgeo.c(899) : error C2065: 'NAN' : undeclared identifier
> 
>  > > shpgeo.c(909) : error C2065: 'NAN' : undeclared identifier
> 
>  > > shpgeo.c(910) : error C2065: 'NAN' : undeclared identifier
> 
>  > > shpgeo.c(1021) : error C2065: 'NAN' : undeclared identifier
> 
>  > > shpgeo.c(1022) : error C2065: 'NAN' : undeclared identifier
> 
>  > > Generating Code...
> 
>  > > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
> 
>  > > Studio 11.0\VC\BIN\cl.EXE"' : return code '0x2'
> 
>  > > Stop.
> 
>  > >
> 
>  > >
> 
>  > > Please let me know if there is another way to compile the contrib
> 
>  > > utilities. thanks,
> 
>  >
> 
>  > I figured it out: I copied the missing file /contrib/my_nan.h from the
> 
>  > 1.3.0 release into my 1.4.0 contrib folder, and added the following into
> 
>  > contrib/shpgeo.c
> 
>  >
> 
>  > #ifdef NAN
> 
>  > #include "my_nan.h"
> 
>  > #endif
> 
> Hi Jeff,
> 
> Should probably read #ifndef NAN, right ?


Hi Even,

Yes of course, I was typing too fast ha.

> 
> I'm not completely clear when my_nan.h disappeared from the repository. 
> Nothing explicit in the changelog.

I also looked, couldn't find any reference.

> 
> Instead of this change, can you try the following instead ?
> 
> {{{
> 
> diff -u -r1.15 shpgeo.c
> 
> --- contrib/shpgeo.c 6 Dec 2016 21:13:33 -0000 1.15
> 
> +++ contrib/shpgeo.c 10 Jul 2017 17:32:52 -0000
> 
> @@ -99,6 +99,12 @@
> 
> #include "shpgeo.h"
> 
> +#if defined(_MSC_VER) && _MSC_VER < 1800
> 
> +#include <float.h>
> 
> +#define INFINITY (DBL_MAX + DBL_MAX)
> 
> +#define NAN (INFINITY - INFINITY)
> 
> +#endif
> 
> +
> 
> /* I'm using some shorthand throughout this file
> 
> * R+ is a Clockwise Ring and is the positive portion of an object
> 
> }}}

That worked, much nicer, thanks!

-jeff





More information about the Shapelib mailing list