Solution to compilation and Link error when building cocosd-x v3.2 using ndk R10

Source: Internet
Author: User

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 declarationssize_t BundleReader::tell()  ^/Users/minggo/SourceCode/cocos2d-x/build/../cocos/./3d/CCBundleReader.h:90:14: note:   previous declaration is herelong 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.