basemap icon indicating copy to clipboard operation
basemap copied to clipboard

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

Open fmv1992 opened this issue 8 years ago • 8 comments

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,

fmv1992 avatar Aug 22 '16 19:08 fmv1992

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

WeatherGod avatar Aug 22 '16 20:08 WeatherGod

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.

cgohlke avatar Aug 22 '16 21:08 cgohlke

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?

fmv1992 avatar Aug 23 '16 12:08 fmv1992

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 [email protected] 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 <math.h>

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

endif

#endif

to

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

include <math.h>

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 .

WeatherGod avatar Aug 23 '16 13:08 WeatherGod

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.

micahcochran avatar Aug 23 '16 15:08 micahcochran

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 avatar Jun 18 '18 16:06 DrNickBailey

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

DrNickBailey avatar Jun 18 '18 16:06 DrNickBailey