0
\$\begingroup\$

I was trying to compile cocos2d-x on my linux machine, because they do not provide a binary copy of the library. However, I received the following error during the build:

/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp: In member function ‘virtual void cocos2d::OrbitCamera::startWithTarget(cocos2d::Node*)’:
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:193:22: error: ‘isnan’ was not declared in this scope
     if( isnan(_radius) )
                      ^
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:193:22: note: suggested alternative:
In file included from /usr/include/c++/4.9/random:38:0,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccRandom.h:29,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccMacros.h:73,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/math/CCGeometry.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCAction.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionInterval.h:33,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.h:31,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:28:
/usr/include/c++/4.9/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:195:22: error: ‘isnan’ was not declared in this scope
     if( isnan(_angleZ) )
                      ^
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:195:22: note: suggested alternative:
In file included from /usr/include/c++/4.9/random:38:0,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccRandom.h:29,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccMacros.h:73,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/math/CCGeometry.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCAction.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionInterval.h:33,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.h:31,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:28:
/usr/include/c++/4.9/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:197:22: error: ‘isnan’ was not declared in this scope
     if( isnan(_angleX) )
                      ^
/home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:197:22: note: suggested alternative:
In file included from /usr/include/c++/4.9/random:38:0,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccRandom.h:29,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/base/ccMacros.h:73,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/math/CCGeometry.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCAction.h:32,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionInterval.h:33,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.h:31,
                 from /home/ryan/Downloads/cocos/cocos2d-x-3.11.1/cocos/2d/CCActionCamera.cpp:28:
/usr/include/c++/4.9/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^
cocos/CMakeFiles/cocos2dInternal.dir/build.make:86: recipe for target 'cocos/CMakeFiles/cocos2dInternal.dir/2d/CCActionCamera.cpp.o' failed
make[2]: *** [cocos/CMakeFiles/cocos2dInternal.dir/2d/CCActionCamera.cpp.o] Error 1
CMakeFiles/Makefile2:463: recipe for target 'cocos/CMakeFiles/cocos2dInternal.dir/all' failed
make[1]: *** [cocos/CMakeFiles/cocos2dInternal.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I have installed all of the dependencies, to my knowledge. Did I do something wrong or is this a known issue that I've encountered?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

While not having experience with Cocos2D, I'd guess that you'll need to replace isnan with std::isnan. If that works, it's a portability bug in Cocos2D because on some compilers/standard libraries some methods can be called without std::.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ To support your answer, it's worth nothing the compiler literally says "error: ‘isnan’ was not declared in this scope", "note: suggested alternative: ‘std::isnan’" \$\endgroup\$
    – user5665
    Commented Jul 28, 2016 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .