cocos jni编译出错
我用androidstudio和cocos对接,然后用cocos编译文件出现错误了。错误详情如下:make:***Waitingforunfinishedjobs.......
我用android studio和cocos对接,然后用cocos编译文件出现错误了。错误详情如下:
make: *** Waiting for unfinished jobs....
[armeabi] Compile++ thumb: cocos_ui_static <= UIRichText.cpp
In file included from /Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./base/ccUTF8.h:34:0,
from /Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/ui/UITextField.cpp:28:
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:36:5: error: 'JNIEnv' does not name a type
JNIEnv * env;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:37:5: error: 'jclass' does not name a type
jclass classID;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:38:5: error: 'jmethodID' does not name a type
jmethodID methodID;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:45:12: error: 'JavaVM' does not name a type
static JavaVM* getJavaVM();
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:46:12: error: 'JNIEnv' does not name a type
static JNIEnv* getEnv();
^ 展开
make: *** Waiting for unfinished jobs....
[armeabi] Compile++ thumb: cocos_ui_static <= UIRichText.cpp
In file included from /Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./base/ccUTF8.h:34:0,
from /Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/ui/UITextField.cpp:28:
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:36:5: error: 'JNIEnv' does not name a type
JNIEnv * env;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:37:5: error: 'jclass' does not name a type
jclass classID;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:38:5: error: 'jmethodID' does not name a type
jmethodID methodID;
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:45:12: error: 'JavaVM' does not name a type
static JavaVM* getJavaVM();
^
/Users/ouzhou/Documents/JNITests/JNICocosTest/proj.android-studio/../cocos2d/cocos/./platform/android/jni/JniHelper.h:46:12: error: 'JNIEnv' does not name a type
static JNIEnv* getEnv();
^ 展开
1个回答
展开全部
1. fatal error: CCMenuItem.h: No such file or directory
这是因为工程中AppDelagete.cpp包含了这个头文件,但是在头文配源件搜寻路径中没有找到该文件。
在vs或其他ide上一般只要设置工程属性就行了。比如vs2012:
工程属性面板->配置属性->C/C++->附加包含目录,加上cocos2d-x/cocos/2d就行了。
设置了培则态ide的工程属性后,对于命令行编译打包到android平台apk仍然会提示这个问题。这时候就需要在Android.mk里面设置,让编译程序能够找到对应的头文件。比如这种情况就可以这样设置:
在Andoroid.mk (proj.android\jni\下面)里面把头文件加入LOCAL_C_INCLUDES,比如将
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
改成
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../cocos2d/cocos/2d \
$(LOCAL_PATH)/../../Classes
这里我原以为是要在Android.mk里面加入一行$(call import-module,2d)。结果这样做导致提示2d这个模块找不到,进而错误地认为是ndk路径设置不对:
Android NDK: F:\Tech\Projects\Cocos2d-x\Earlybird\Earlybird-3.1\proj.android\../
cocos2d/cocos/audio/android/Android.mk: Cannot find module with tag '2d' in impo
rt path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
make.exe: Entering directory `F:/Tech/Projects/Cocos2d-x/Earlybird/Earlybird-3.1
/proj.android'
jni/Android.mk:35: *** Android NDK: Aborting. . Stop.
后来才发现应该是LOCAL_C_INCLUDES里盯雹面添加。
2. 如下错误信息:
[armeabi] SharedLibrary : libcocos2dcpp.so
jni/../../Classes/LoadingScene.h:30: error: undefined reference to 'LoadingScene
::LoadingScene()'
jni/../../Classes/HelloWorldScene.cpp:53: error: undefined reference to 'AtlasLo
ader::getInstance()'
很明显,这里没有找到对应的LoadingScene.cpp和AtlasLoader.cpp文件。这两个文件都在../../Classes文件夹里面。但是在Android.mk里面../../Classes只是头文件的搜索路径,没有放到编译的文件里面。所以这里在链接的时候找不到对应的源文件。应该在LOCAL_SRC_FILES里面加入,将
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
改成
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/AtlasLoader.cpp \
../../Classes/BackgroundLayer.cpp \
../../Classes/BirdSprite.cpp \
../../Classes/GameLayer.cpp \
../../Classes/GameScene.cpp \
../../Classes/LoadingScene.cpp \
../../Classes/MenuScene.cpp \
../../Classes/Number.cpp \
../../Classes/OptionLayer.cpp \
../../Classes/StatusLayer.cpp \
../../Classes/WelcomeLayer.cpp \
../../Classes/WelcomeScene.cpp \
../../Classes/UserRecord.cpp \
这是因为工程中AppDelagete.cpp包含了这个头文件,但是在头文配源件搜寻路径中没有找到该文件。
在vs或其他ide上一般只要设置工程属性就行了。比如vs2012:
工程属性面板->配置属性->C/C++->附加包含目录,加上cocos2d-x/cocos/2d就行了。
设置了培则态ide的工程属性后,对于命令行编译打包到android平台apk仍然会提示这个问题。这时候就需要在Android.mk里面设置,让编译程序能够找到对应的头文件。比如这种情况就可以这样设置:
在Andoroid.mk (proj.android\jni\下面)里面把头文件加入LOCAL_C_INCLUDES,比如将
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
改成
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../cocos2d/cocos/2d \
$(LOCAL_PATH)/../../Classes
这里我原以为是要在Android.mk里面加入一行$(call import-module,2d)。结果这样做导致提示2d这个模块找不到,进而错误地认为是ndk路径设置不对:
Android NDK: F:\Tech\Projects\Cocos2d-x\Earlybird\Earlybird-3.1\proj.android\../
cocos2d/cocos/audio/android/Android.mk: Cannot find module with tag '2d' in impo
rt path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
make.exe: Entering directory `F:/Tech/Projects/Cocos2d-x/Earlybird/Earlybird-3.1
/proj.android'
jni/Android.mk:35: *** Android NDK: Aborting. . Stop.
后来才发现应该是LOCAL_C_INCLUDES里盯雹面添加。
2. 如下错误信息:
[armeabi] SharedLibrary : libcocos2dcpp.so
jni/../../Classes/LoadingScene.h:30: error: undefined reference to 'LoadingScene
::LoadingScene()'
jni/../../Classes/HelloWorldScene.cpp:53: error: undefined reference to 'AtlasLo
ader::getInstance()'
很明显,这里没有找到对应的LoadingScene.cpp和AtlasLoader.cpp文件。这两个文件都在../../Classes文件夹里面。但是在Android.mk里面../../Classes只是头文件的搜索路径,没有放到编译的文件里面。所以这里在链接的时候找不到对应的源文件。应该在LOCAL_SRC_FILES里面加入,将
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
改成
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/AtlasLoader.cpp \
../../Classes/BackgroundLayer.cpp \
../../Classes/BirdSprite.cpp \
../../Classes/GameLayer.cpp \
../../Classes/GameScene.cpp \
../../Classes/LoadingScene.cpp \
../../Classes/MenuScene.cpp \
../../Classes/Number.cpp \
../../Classes/OptionLayer.cpp \
../../Classes/StatusLayer.cpp \
../../Classes/WelcomeLayer.cpp \
../../Classes/WelcomeScene.cpp \
../../Classes/UserRecord.cpp \
追问
额。。。。你是不是回复错人了?我的错误都不是你说的那些。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询