包括Protobuf库 - cocos2dx

时间:2015-01-15 07:09:17

标签: android c++ cocos2d-x protocol-buffers android.mk

您好我想将protobufs添加到我的项目中。到目前为止,我只是尝试使用android并且到目前为止还不幸运。

我已将我的libs:libprotobuf.a,libprotobuf-lite.a,libprotoc.a放在“Protobuf”文件夹中,可以找到“Classes”文件夹。 我生成了一个名为“Msg.pb.cc”的Proto并将其放在Classes文件夹中。 我已将Protobuf .h文件放在classes文件夹中。即Classes / google / protobuf /....

这就是我的Android.mk现在的样子。

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := libprotoc
LOCAL_SRC_FILES := ../../Protobuf/libprotoc.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := libprotobuf-lite
LOCAL_SRC_FILES := ../../Protobuf/libprotobuf-lite.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := libprotobuf.a
LOCAL_SRC_FILES := ../../Protobuf/libprotobuf.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_CPP_EXTENSION := .cxx .cpp .cc

LOCAL_SRC_FILES += hellocpp/main.cpp \
               ../../Classes/AppDelegate.cpp \
               ../../Classes/GameSprite.cpp \
               ../../Classes/GameLayer.cpp \
               ../../Classes/Control.cpp \
               ../../Classes/HelloWorldScene.cpp \
               ../../Classes/NativeInterface.cpp \
               ../../Classes/Msg.pb.cc 


LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes 

LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static

include $(BUILD_SHARED_LIBRARY)


$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
$(call import-module,external/Box2D)
$(call import-module,external/chipmunk)

编译Msg.pb.cc后,我会收到很多错误。这里有几个:

E:/Android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/Msg.pb.o: in function env10us::Msg::ByteSize() const:jni/../../Classes/google/protobuf/io/coded_stream.h:1091: error: undefined reference to 'google::protobuf::io::CodedOutputStream::VarintSize32Fallback(unsigned int)'
E:/Android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/Msg.pb.o: in function env10us::Msg::ByteSize() const:jni/../../Classes/google/protobuf/io/coded_stream.h:1091: error: undefined reference to 'google::protobuf::io::CodedOutputStream::VarintSize32Fallback(unsigned int)'
E:/Android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/Msg.pb.o: in function env10us::Msg::ByteSize() const:jni/../../Classes/google/protobuf/io/coded_stream.h:1091: error: undefined reference to 'google::protobuf::io::CodedOutputStream::VarintSize32Fallback(unsigned int)'

不知何故,我猜文件没有链接。代码无法找到protobuf库。 我不知道Android.mk文件是如何编写的,并且对cpp也没有多少经验。这只是一些谷歌搜索和阅读原始Android.mk文件的结果。 任何帮助表示赞赏。

-cocos2dx-2.2.5
-eclipse + ADT。
-sdk 5.0.1
-ndk r8e

0 个答案:

没有答案