coco2dx编译so文件出错解决方法

转载请注明出处:http://blog.csdn.net/coder_jone/article/details/39578537


今天在使用cocos2dx项目中proj.andriod目录下的build_native.py打包so文件时报错:

The Selected NDK toolchain version was 4.8 !
Android NDK: WARNING:jni/../../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL
_LDLIBS is always ignored for static libraries
Android NDK: WARNING:jni/../../cocos2d/cocos/platform/android/Android.mk:cocos2d
xandroid_static: LOCAL_LDLIBS is always ignored for static libraries
make.exe: Entering directory `F:/cocoprojects/DontTouckWhiteBlok/proj.android'
[armeabi] Compile++ thumb: cocos2dcpp_shared <= main.cpp
[armeabi] Compile++ thumb: cocos2dcpp_shared <= AppDelegate.cpp
[armeabi] Compile++ thumb: cocos2dcpp_shared <= HelloWorldScene.cpp
[armeabi] SharedLibrary  : libcocos2dcpp.so
jni/../../Classes/HelloWorldScene.cpp:91: error: undefined reference to 'Block::
createWithArgs(cocos2d::Color3B, cocos2d::Size, float, std::__1::basic_string, std::__1::allocator >, cocos2d::Color4B)'

jni/../../Classes/HelloWorldScene.cpp:93: error: undefined reference to 'Block::
setLineIndex(int)'
jni/../../Classes/HelloWorldScene.cpp:110: error: undefined reference to 'Block:
:createWithArgs(cocos2d::Color3B, cocos2d::Size, float, std::__1::basic_string, std::__1::allocator >, cocos2d::Color4B)
'
jni/../../Classes/HelloWorldScene.cpp:113: error: undefined reference to 'Block:
:setLineIndex(int)'
jni/../../Classes/HelloWorldScene.cpp:98: error: undefined reference to 'Block::
createWithArgs(cocos2d::Color3B, cocos2d::Size, float, std::__1::basic_string, std::__1::allocator >, cocos2d::Color4B)'

jni/../../Classes/HelloWorldScene.cpp:100: error: undefined reference to 'Block:
:setLineIndex(int)'
jni/../../Classes/HelloWorldScene.cpp:128: error: undefined reference to 'Block:
:getBlocks()'
jni/../../Classes/HelloWorldScene.cpp:131: error: undefined reference to 'Block:
:moveDown()'
jni/../../Classes/HelloWorldScene.cpp:43: error: undefined reference to 'Block::
getBlocks()'
jni/../../Classes/HelloWorldScene.cpp:48: error: undefined reference to 'Block::
getLineIndex()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invoca
tion)
make.exe: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make.exe: Leaving directory `F:/cocoprojects/DontTouckWhiteBlok/proj.android'
Traceback (most recent call last):
  File "F:\cocoprojects\DontTouckWhiteBlok\proj.android\build_native.py", line 1
59, in 
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File "F:\cocoprojects\DontTouckWhiteBlok\proj.android\build_native.py", line 1
46, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and
roid_platform,build_mode)
  File "F:\cocoprojects\DontTouckWhiteBlok\proj.android\build_native.py", line 8
2, in do_build
    raise Exception("Build dynamic library for project [ " + app_android_root +
" ] fails!")
Exception: Build dynamic library for project [ F:\cocoprojects\DontTouckWhiteBlo
k\proj.android ] fails!
在网上找了下,原来是我新加的类没有在mk文件中加入,找到\proj.android\jni目录下的Android.mk文件,打开并在LOCAL_SRC_FILES下加入新添加的cpp文件,如:../../Classes/Test.cpp,保存再执行build_native.py编译通过。





你可能感兴趣的:(coso2dx游戏开发)