0

我在 android cocos2d-x 项目中运行 build_native.sh 时遇到问题。原来是一些链接问题。我创建的 cpp 文件未编译,因此成为未定义的引用。

这是错误:

SoybeanServer-2:android soybeansoft$ ./build_native.sh 
Using prebuilt externals
make: Entering directory `/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android'
SharedLibrary  : libgame.so
./obj/local/armeabi/objs/game_shared/__/__/Classes/AppDelegate.o: In function `AppDelegate::applicationDidFinishLaunching()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/AppDelegate.cpp:111: undefined reference to `MainMenu::scene()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::okButtonCallback(cocos2d::CCObject*)':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:179: undefined reference to `Logic::select()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::newQuiz()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:172: undefined reference to `Logic::getCurrentQuiz()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:173: undefined reference to `Logic::getCurrentQuiz()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::swipeRight()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:151: undefined reference to `Logic::nextImage()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::swipeLeft()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:145: undefined reference to `Logic::previousImage()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `~HelloWorld':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:16: undefined reference to `Logic::unregisterEventHandler()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:30: undefined reference to `LogicEvent::~LogicEvent()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:16: undefined reference to `Logic::unregisterEventHandler()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:30: undefined reference to `LogicEvent::~LogicEvent()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:9: undefined reference to `Logic::Logic()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:9: undefined reference to `Logic::Logic()'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::imageChanged()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:161: undefined reference to `Logic::getCurrentImage()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:162: undefined reference to `MemeImage::setImage(char const*)'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o: In function `HelloWorld::init()':
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:83: undefined reference to `MemeImage::MemeImage()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:90: undefined reference to `Logic::init(float)'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:91: undefined reference to `Logic::registerEventHandler(LogicEvent*)'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:93: undefined reference to `Logic::getCurrentQuiz()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:94: undefined reference to `Logic::getCurrentQuiz()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:96: undefined reference to `Logic::getCurrentQuiz()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:102: undefined reference to `Logic::getCurrentImage()'
/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android/jni/../../Classes/HelloWorldScene.cpp:103: undefined reference to `MemeImage::setImage(char const*)'
./obj/local/armeabi/objs/game_shared/__/__/Classes/HelloWorldScene.o:(.data.rel.ro+0x1d0): undefined reference to `typeinfo for LogicEvent'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1
make: Leaving directory `/Users/soybeansoft/devs/cocos2d-x_1.0/MemeQuiz/android'
SoybeanServer-2:android soybeansoft$ 

有人说我需要列出我在 Classes 文件夹中的 Android.mk 文件中创建的所有 cpp 文件。但是在我查看 Classes 文件夹后,那里没有 Android.mk。那么我现在应该如何列出 .cpp 文件呢?

更新 :

我知道 jni 文件夹中有 android.mk 文件。但即使我在那里列出了我所有的游戏 cpp 文件,cpp 仍然没有在 build_native 过程中编译。所以我真的不知道如何列出我的 cpp 文件。

4

1 回答 1

0

android.mk 文件将位于 eclipse 项目的 jni 文件夹中。看那边。

于 2012-08-14T08:35:39.553 回答