If you build Cocos2d-x v3.2 using ndk R10, you will encounter all test case compilation errors and Lua test case Link errors.
1. Compilation Error
The error message is:
12345678 |
/Users/minggo/SourceCode/cocos2d-x/build/../cocos/./3d/CCBundleReader.cpp:94:23: error: return type of out-of-line definition of ‘cocos2d::BundleReader::tell‘ differs from that in the declaration ssize_t BundleReader::tell() ^ /Users/minggo/SourceCode/cocos2d-x/build/../cocos/./3d/CCBundleReader.h:90:14: note: previous declaration is here long int tell(); |
Compilation errors are fixed here. We are sorry for this.
2. Link error
After the compilation error is fixed, you will encounter a link error when creating a Lua test case or a new Lua project.
I have submitted this error in the android problem feedback system. Ndk developers admit that this is a bug in ndk R10. There are two solutions:
1) Use the command line "-nodefaultlibs-lstdc ++-latomic-LDL-lm-LC-lcompiler_rt_static" to change the generated file to libgcc..
However, because we use an independent tool chain, changing the file generation won't work for the Cocos2d-x.
2) use libc ++ _ shared. So, add libcxx_use_gabixx: = true to application. mk, and use Gabi ++ to recreate libc ++.
This method requires a shared library, and you also need to modify cocos2dxactivity. Java to load the dependent shared library. We do not want to make such changes because:
* We have not tested the shared library, so we have never used the shared library.
* A shared database is 0.13 m larger than a .apk generated using a static database.
* Google developers will fix this issue in the next generation of ndk
Summary
We recommend that you use ndk r9d instead of ndk R10. If you use ndk R10, the following steps can help you solve the above two problems:
1) Change long int to ssize_t when declaring bundlereader: Tell. For more details, see this PR.
2) Change app_stl: = C ++ _ static to app_stl: = C ++ _ shared. Add libcxx_use_gabixx: = true to application. mk, and modify your Java activation code to load libc ++ _ shared. So. For more details, see this PR.
Source: http://cocos2d-x.org/news/307
Solution to compilation and Link error when building cocosd-x v3.2 using ndk R10