cocos2dx 3.9 升级 3.17

1.更改环境变量,使用cocos2dx3.17

2.想新工程中添加三方库

3.跟新工程头文件引用

4.openssl冲突修改三方库的函数引用中cocos自带的库

5.添加android app/android.mk 头文件引用,注意相对路径

6.android编译错误:

cocos compile --compile-script 0 -m release -p android
 /Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/jni/../../../Classes/Foxair/atomic.cpp:15:10: fatal error: 'sys/atomics.h' file not found
  #include <sys/atomics.h>
           ^~~~~~~~~~~~~~~
  1 error generated.
  make: *** [/Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2dlua_shared/__/__/__/Classes/Foxair/atomic.o] Error 1
  make: *** Waiting for unfinished jobs....

ndk低版本中sys/atomics.h被stdatomics.h替换,使用其中函数重写:

#include <stdatomic.h>
int atomicDecrement(volatile int* t) {
    __sync_fetch_and_sub(t, 1);
    return *t;
}
int atomicIncrement(volatile int* t) {
    __sync_fetch_and_add(t, 1);
    return *t;
}
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)

7.

  /Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/jni/../../../Classes/Foxair/game_connection.cpp:24:10: fatal error: 'sys/timeb.h' file not found
  #include <sys/timeb.h>
           ^~~~~~~~~~~~~
  1 error generated.
  make: *** [/Users/admin/code/cocos/new/project_wly2_lua_client/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2dlua_shared/__/__/__/Classes/Foxair/game_connection.o] Error 1
  make: *** Waiting for unfinished jobs....
#include <sys/time.h>

struct timeval tp;
gettimeofday(&tp, NULL);
//当前时间
long long now = (long long)tp.tv_sec * 1000 + (long long)tp.tv_usec;
Mutex::ScopedLock timestampLock(m_timestampMutex);

 

 

配置要求:

android-ndk-r16b

android-sdk-macosx

# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=27

# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=14

# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=27

# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=27.0.1

# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=armeabi-v7a

# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=ndk-build

android studio 3.3

编译模式:release
使用 Android Studio 工程:/Users/admin/code/client/project_wly2_lua_client/frameworks/runtime-src/proj.android
配置文件 '/Users/admin/code/client/project_wly2_lua_client/frameworks/runtime-src/proj.android/build-cfg.json' 不存在或者已损坏。

修改.cocos_project文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值