wwisesamples / cocos2dx-IntegrationDemo

Integrate Wwise in cocos2d-x platform
32 stars 10 forks source link

[With workaround and fix] Demo fails to compile using Wwise 2015.1.6 with Cocos2dx 3.10 #3

Open kakyoism opened 8 years ago

kakyoism commented 8 years ago

Environment:

Repro:

  1. Do everything according to the README at: WwiseDemo-cocos2dx\Readme Android.txt. until Step 4.2.
  2. Compile the Release version.

Error:

The compilation fails with the following error:

make.exe: Entering directory c:/Audiokinetic/Wwise_v2015.1.6_build_5553/SDK/samples/IntegrationDemo/cocos2d-x/proj.android' C:/NVPACK/android-ndk-r10e/build/core/build-binary.mk:466: warning: overriding commands for targetobj/local/armeabi-v7a/objs-debug/bullet_static/BulletMultiThreaded/SpuLibspe2Support.o' C:/NVPACK/android-ndk-r10e/build/core/build-binary.mk:466: warning: ignoring old commands for target `obj/local/armeabi-v7a/objs-debug/bullet_static/BulletMultiThreaded/SpuLibspe2Support.o' [armeabi-v7a] Compile++ arm : cocos2dcpp_shared <= WwiseWrapper.cpp [armeabi-v7a] Compile++ arm : cocos2dcpp_shared <= AkFileHelpers.cpp [armeabi-v7a] Compile++ arm : cocos2dcpp_shared <= AkDefaultIOHookBlocking.cpp [armeabi-v7a] Compile++ arm : cocos2dcpp_shared <= Helpers.cpp C:\Audiokinetic\Wwise_v2015.1.6_build_5553\SDK/samples/SoundEngine/Android/AkFileHelpers.cpp:16:17: fatal error: zip.h: No such file or directory

include

             ^

compilation terminated. make.exe: [obj/local/armeabi-v7a/objs-debug/cocos2dcppshared/C\Audiokinetic\Wwise_v2015.1.6_build_5553\SDK/samples/SoundEngine/Android/AkFileHelpers.o] Error 1 make.exe: Waiting for unfinished jobs.... jni/../../Classes/WwiseWrapper.cpp: In function 'void LOGAKW(AkOSChar)': jni/../../Classes/WwiseWrapper.cpp:30:70: warning: format not a string literal and no format arguments [-Wformat-security] __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, (const char)&szBuff); ^ jni/../../Classes/WwiseWrapper.cpp: In function 'bool WWISE::initialize(void)': jni/../../Classes/WwiseWrapper.cpp:271:44: error: 'class CAkFilePackageLowLevelIOBlocking' has no member named 'SetAssetManager' Wwise::Instance().GetLowLevelIOHandler()->SetAssetManager((AAssetManager)mgr); ^ At global scope: cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat" cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat" make.exe: *** [obj/local/armeabi-v7a/objs-debug/cocos2dcpp_shared///Classes/WwiseWrapper.o] Error 1 make.exe: Leaving directory`c:/Audiokinetic/Wwise_v2015.1.6_build_5553/SDK/samples/IntegrationDemo/cocos2d-x/proj.android' Error running command, return code: 2.

Diagnostics:

  1. - This seems to be caused by the newly-introduced libzip for the OBB feature.
  2. - AssetManager code has changed: It's now encapsulated into the sample code samples/SoundEngine/Android/AkFileHelpers.h/.cpp inside the CAkAPKLocation class (for the better).

Workarounds:

For Error #1: Add this line to the proj.android/jni/Android.mk among the LOCAL_C_INCLUDES assignments: LOCAL_C_INCLUDES += ${WWISESDK}/samples/SoundEngine/Android/libzip/lib

However, you'll soon run into linker error too. So you need to add libzip dependency into your makefile:

Add this to the end of your library module block:

include $(CLEAR_VARS)
LOCAL_MODULE            := zip
LOCAL_SRC_FILES         := $(SDK_LIB_DIR)/libzip.a 
include $(PREBUILT_STATIC_LIBRARY)

Then add this to the end of your "LOCAL_STATIC_LIBRARIES" linker flag:

zip

Don't forget to add the trailing "\" to the lib before it.

For Error #2: Remove the following line from the cocos2dx-demo code C:\Audiokinetic\Wwise_v2015.1.6_build_5553\SDK\samples\IntegrationDemo\cocos2d-x\Classes\WwiseWrapper.cpp: Wwise::Instance().GetLowLevelIOHandler()->SetAssetManager((AAssetManager*)mgr); Since AssetManager is now hidden to low-level I/O's client code, the proper fix would be to remove the AssetManager dependency from WwiseWrapper altogether.

Finally, recompile the demo and you should be good to go.

kakyoism commented 8 years ago

The workaround to Error #1 one above is only to fix the compilation error. You'll need a complete fix to avoid a crash on Android.

Go to my fork to get the complete fix: https://github.com/kakyoism/cocos2dx-IntegrationDemo

Tested and worked with Wwise v2015.1.6 on an Android 4.2 device.

I sent a pull request .