/opt/cocos2d-x/cocos/2d/CCActionCamera.cpp:197:22: error: ‘isnan’ was not declared in this scope
if( isnan(_angleX) )
^
/opt/cocos2d-x/cocos/2d/CCActionCamera.cpp:197:22: note: suggested alternative:
In file included from /usr/include/c++/5.3.0/random:38:0,
from /opt/cocos2d-x/cocos/base/ccRandom.h:29,
from /opt/cocos2d-x/cocos/base/ccMacros.h:73,
from /opt/cocos2d-x/cocos/math/CCGeometry.h:32,
from /opt/cocos2d-x/cocos/2d/CCAction.h:32,
from /opt/cocos2d-x/cocos/2d/CCActionInterval.h:33,
from /opt/cocos2d-x/cocos/2d/CCActionCamera.h:31,
from /opt/cocos2d-x/cocos/2d/CCActionCamera.cpp:28:
/usr/include/c++/5.3.0/cmath:641:5: note: ‘std::isnan’
isnan(_Tp __x)
cocos/CMakeFiles/cocos2d.dir/build.make:86: recipe for target 'cocos/CMakeFiles/cocos2d.dir/2d/CCActionCamera.cpp.o' failed
make[2]: *** [cocos/CMakeFiles/cocos2d.dir/2d/CCActionCamera.cpp.o] Error 1
CMakeFiles/Makefile2:419: recipe for target 'cocos/CMakeFiles/cocos2d.dir/all' failed
make[1]: *** [cocos/CMakeFiles/cocos2d.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
This is resolved by simply running:
sed -i 's/isnan/std::isnan/g' `grep "isnan" -rl`
The second issue (UNRESOLVED):
[ 17%] Building C object cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/__/__/__/external/lua/lua/ltable.c.o
In file included from /home/eht/tools/cocos2d-x-3.10/external/lua/lua/lua.h:16:0,
from /home/eht/tools/cocos2d-x-3.10/external/lua/lua/ltable.c:27:
/home/eht/tools/cocos2d-x-3.10/external/lua/lua/luaconf.h:543:20: warning: ISO C99 requires whitespace after the macro name
#define luai_numstd::isnan(a) (!luai_numeq((a), (a)))
^
/home/eht/tools/cocos2d-x-3.10/external/lua/lua/ltable.c: In function ‘luaH_set’:
/home/eht/tools/cocos2d-x-3.10/external/lua/lua/luaconf.h:543:20: error: expected expression before ‘:’ token
#define luai_numstd::isnan(a) (!luai_numeq((a), (a)))
^
/home/eht/tools/cocos2d-x-3.10/external/lua/lua/ltable.c:501:33: note: in expansion of macro ‘luai_numstd’
else if (ttisnumber(key) && luai_numstd::isnan(nvalue(key)))
^
cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/build.make:302: recipe for target 'cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/__/__/__/external/lua/lua/ltable.c.o' failed
make[2]: *** [cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/__/__/__/external/lua/lua/ltable.c.o] Error 1
CMakeFiles/Makefile2:672: recipe for target 'cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/all' failed
make[1]: *** [cocos/scripting/lua-bindings/CMakeFiles/luacocos2d.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Hi eht & everybody
I ran at the same problem in 16.04.
I used your solution and it (nearly) works and fixed nicely the fist issue, with exception to a few cases described below.
Concerning your Issue #2:
Apparently there happened to appear luai_num::isnan and your sed changed it to luai_numstd::isnan which was probably not what you intended. Another error introduced by this sed was that std::isnan which already existed at certain places in code was changed to std::std::isnan, so I had to modify your sed to revert double std to single one.
I cloned probably yesterday.
I found some problems related with multithreaded compilation (make -j4).
I resolved them by running ‘make -j4’ a few times.
Apparently build was finished with no errors, however I didn’t try to compile my project yet.
Apart from this problem, I had no problems, after fixing this issue the cpp_tests ran with no problems.
So, I downloaded 16.04, installed in a VMWare Fusion virtual machine and followed these steps and it worked up, until I tried to compile cpp-tests. I too see the isnan error. Did anyone make a GitHub issue for this yet?
error: ‘glfwSetWindowMonitor’ was not declared in this scope
recipe for target ‘cocos2d/cocos/CMakeFiles/cocos2dInternal.dir/platform/desktop/CCGLViewImpl-desktop.cpp.o’ failed
recipe for target ‘cocos2d/cocos/CMakeFiles/cocos2dInternal.dir/all’ failed
recipe for target ‘all’ failed
I found the same problem, and I solved it downloading glfw3 library.
My steps:
$git clone https://github.com/glfw/glfw
$mkdir build
$cd build
$cmake …/glfw
$make -j4
$sudo make install
And then I done a symbolic link to libglfw3.a as libglfw.a
$cd /usr/local/lib
$sudo ln -s libglfw3.a libglfw.a
With theses steps cocos2d-x works for me.
My Operating System: Ubuntu 16.04
My IDE: Code::Blocks 16.01 rev 10760
Cocos2d-x version 3.14.1
I’m having a new problem when I add a new Class to cocosd2-x project the compiler shows an error about “the class is not defined”.
I can solve this error if I add my cpp and h files inside CMakeList.txt file in the same location of AppDelegate and HelloWorldScene files. But it implies rebuild entire proyect (cocos2d-x library).
Can someone explain me how to add new classes in cocosd2-x project with the Code::Blocks IDE?