matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
780 stars 392 forks source link

Cygwin install error: error: 'isnan' was not declared in this scope #314

Open fmv1992 opened 8 years ago

fmv1992 commented 8 years ago

Dear all,

after struggling with the installation of basemap I decided to post here. I have tried a couple of different 'hacks' found in google but none worked.

Full error:

libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../../include -I../../../include/geos -I../../../include -DGEOS_INLINE -pedantic -Wall -ansi -Wno-long-long -ffloat-store -g -O2 -MT IndexedPointInAreaLocator.lo -MD -MP -MF .deps/IndexedPointInAreaLocator.Tpo -c IndexedPointInAreaLocator.cpp -DDLL_EXPORT -DPIC -o .libs/IndexedPointInAreaLocator.o In file included from ../../../include/geos/geom/Geometry.h:26:0, from IndexedPointInAreaLocator.cpp:18: ../../../include/geos/geom/Coordinate.inl: In member function 'bool geos::geom::Coordinate::isNull() const': ../../../include/geos/platform.h:88:27: error: 'isnan' was not declared in this scope

define ISNAN(x) (isnan(x))

                       ^

../../../include/geos/geom/Coordinate.inl:39:10: note: in expansion of macro 'ISNAN' return (ISNAN(x) && ISNAN(y) && ISNAN(z)); ^ ../../../include/geos/platform.h:88:27: note: suggested alternative:

define ISNAN(x) (isnan(x))

                       ^

../../../include/geos/geom/Coordinate.inl:39:10: note: in expansion of macro 'ISNAN' return (ISNAN(x) && ISNAN(y) && ISNAN(z)); ^ In file included from ../../../include/geos/geom/Coordinate.inl:23:0, from ../../../include/geos/geom/Coordinate.h:161, from ../../../include/geos/geom/Envelope.h:26, from ../../../include/geos/geom/Geometry.h:28, from IndexedPointInAreaLocator.cpp:18: /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/cmath:862:5: note: 'std::isnan' isnan(_Tp __f) ^ In file included from ../../../include/geos/geom/Geometry.h:26:0, from IndexedPointInAreaLocator.cpp:18: ../../../include/geos/geom/Coordinate.inl: In member function 'bool geos::geom::Coordinate::equals3D(const geos::geom::Coordinate&) const': ../../../include/geos/platform.h:88:27: error: 'isnan' was not declared in this scope

define ISNAN(x) (isnan(x))

                       ^

../../../include/geos/geom/Coordinate.inl:83:21: note: in expansion of macro 'ISNAN' ((z == other.z)||(ISNAN(z) && ISNAN(other.z))); ^ ../../../include/geos/platform.h:88:27: note: suggested alternative:

define ISNAN(x) (isnan(x))

                       ^

../../../include/geos/geom/Coordinate.inl:83:21: note: in expansion of macro 'ISNAN' ((z == other.z)||(ISNAN(z) && ISNAN(other.z))); ^ In file included from ../../../include/geos/geom/Coordinate.inl:23:0, from ../../../include/geos/geom/Coordinate.h:161, from ../../../include/geos/geom/Envelope.h:26, from ../../../include/geos/geom/Geometry.h:28, from IndexedPointInAreaLocator.cpp:18: /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/cmath:862:5: note: 'std::isnan' isnan(_Tp __f) ^ make[4]: * [Makefile:373: IndexedPointInAreaLocator.lo] Error 1 make[4]: Leaving directory '/tmp/basemap/geos-3.3.3/src/algorithm/locate' make[3]: * [Makefile:392: all-recursive] Error 1 make[3]: Leaving directory '/tmp/basemap/geos-3.3.3/src/algorithm/locate' make[2]: * [Makefile:444: all-recursive] Error 1 make[2]: Leaving directory '/tmp/basemap/geos-3.3.3/src/algorithm' make[1]: * [Makefile:476: all-recursive] Error 1 make[1]: Leaving directory '/tmp/basemap/geos-3.3.3/src' make: *\ [Makefile:368: all-recursive] Error 1

I am installing it on cygwin 64 bits.

I have also tried to use cygwin's binaries but they give errors on a tested script.

I am not sure of any additional relevant information.

Best regards,

WeatherGod commented 8 years ago

attn: @cgohlke since you are the only one I know that understands Windows-related compile issues.

cgohlke commented 8 years ago

Well, this is Cygwin, which should behave like Linux. It seems that HAVE_ISNAN is defined even though the Cygwin headers don't have a isnan function. Probably better to install the GEOS library using the Cygwin package management and set the environment variable GEOS_DIR. Or try to patch the platform header to use std::isnan.

fmv1992 commented 8 years ago

I could make it work: On the original file include/geos/platform.h I changed (starting on line 87):

#if defined(HAVE_ISNAN)
# define ISNAN(x) (isnan(x))
#else
# if defined(_MSC_VER)
#  define ISNAN(x) _isnan(x)
# elif defined(__MINGW32__)
// sandro furieri: sanitizing MinGW32
#  define ISNAN(x) (std::isnan(x))
# elif defined(__OSX__) || defined(__APPLE__)
   // Hack for OS/X <cmath> incorrectly re-defining isnan() into oblivion.
   // It does leave a version in std.
#  define ISNAN(x) (std::isnan(x))
# elif defined(__sun) || defined(__sun__)
#  include <math.h>
#  define ISNAN(x) (::isnan(x))
# endif
#endif

to

# define ISNAN(x) (std::isnan(x))
# include <math.h>
# include <cmath>

Should I submit this bug somewhere else to get it corrected for cygwin users?

WeatherGod commented 8 years ago

Yeah, you should check in with the geos folks to figure out what the correct patch should be. I am thinking that there is something special about 64-bit cygwin that is not getting captured by this file. Let me know what the final patch is, and I'll include it here as well.

On Tue, Aug 23, 2016 at 8:36 AM, fmv1992 notifications@github.com wrote:

I could make it work: On the original file include/geos/platform.h I changed (starting on line 87):

if defined(HAVE_ISNAN)

define ISNAN(x) (isnan(x))

else

if defined(_MSC_VER)

define ISNAN(x) _isnan(x)

elif defined(MINGW32)

// sandro furieri: sanitizing MinGW32

define ISNAN(x) (std::isnan(x))

elif defined(OSX) || defined(APPLE)

// Hack for OS/X incorrectly re-defining isnan() into oblivion. // It does leave a version in std.

define ISNAN(x) (std::isnan(x))

elif defined(sun) || defined(__sun)

include

define ISNAN(x) (::isnan(x))

endif

endif

to

define ISNAN(x) (std::isnan(x))

include

include

Should I submit this bug somewhere else to get it corrected for cygwin users?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/314#issuecomment-241716415, or mute the thread https://github.com/notifications/unsubscribe-auth/AARy-KcegKC_gr9PUQxO-5ksLZ8Ys4z5ks5qiuk3gaJpZM4JqOCf .

micahcochran commented 8 years ago

Looks like this has been reported issue for GEOS https://trac.osgeo.org/geos/ticket/630

I wonder if it has actually be patched in the GEOS repository. The basemap supplied version of GEOS is a few releases behind current release.

DrNickBailey commented 6 years ago

When I replace the line in include/geos/platform.h and re-run the make; make install` command the platform.h file gets overwritten resulting in the same error message.

DrNickBailey commented 6 years ago

Ah! Don't replace those lines in the include/geos/platform.h dir, but rather in the basemap install directory .../basemap-1.0.7/geos-3.3.3/include/geos

DWesl commented 2 months ago

Most of my testing for #532 and #582 was done on Cygwin, so I suspect this issue has gone away, one way or another.

As a note: this kind of thing on Cygwin Python packages tends to be a result of

#include <math.h>
#include <Python.h>

rather than the other way around, because Python.h sets a lot of visibility macros that need to be set before any system header is read to be effective. That is, math.h might define isnan, but only if _XOPEN_SOURCE is set, which Python.h does, but with the #include order, that happens only after math.h is done defining things.