日安。我用ndk编译了protobuf 2.4.1库。我从那篇文章中摘录的脚本:How to build protocol buffer by Android NDK
但是当我尝试将我的库链接到测试cocos2d-x项目时,我得到了下一个错误:
SharedLibrary : libgame.so
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o: In function `promowall::RegistrationRequest const* google::protobuf::internal::dynamic_cast_if_available<promowall::RegistrationRequest const*, google::protobuf::Message const*>(google::protobuf::Message const*)':
/usr/include/google/protobuf/generated_message_reflection.h:396: undefined reference to `typeinfo for google::protobuf::Message'
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o: In function `promowall::RegistrationResponse const* google::protobuf::internal::dynamic_cast_if_available<promowall::RegistrationResponse const*, google::protobuf::Message const*>(google::protobuf::Message const*)':
/usr/include/google/protobuf/generated_message_reflection.h:396: undefined reference to `typeinfo for google::protobuf::Message'
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o: In function `promowall::InstallIntentRequest const* google::protobuf::internal::dynamic_cast_if_available<promowall::InstallIntentRequest const*, google::protobuf::Message const*>(google::protobuf::Message const*)':
/usr/include/google/protobuf/generated_message_reflection.h:396: undefined reference to `typeinfo for google::protobuf::Message'
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o: In function `promowall::ItemRequest const* google::protobuf::internal::dynamic_cast_if_available<promowall::ItemRequest const*, google::protobuf::Message const*>(google::protobuf::Message const*)':
/usr/include/google/protobuf/generated_message_reflection.h:396: undefined reference to `typeinfo for google::protobuf::Message'
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o: In function `promowall::ItemResponse const* google::protobuf::internal::dynamic_cast_if_available<promowall::ItemResponse const*, google::protobuf::Message const*>(google::protobuf::Message const*)':
/usr/include/google/protobuf/generated_message_reflection.h:396: undefined reference to `typeinfo for google::protobuf::Message'
./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/protocol.pb.o:/usr/include/google/protobuf/generated_message_reflection.h:396: more undefined references to `typeinfo for google::protobuf::Message' follow
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1从这个日志中我可以看到,编译器找不到消息类型。但源文件message.cc和message_lite.cc包含在libprotobuf.so库中。下面列出了我的测试应用程序Android.mk的源代码
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := protobuf
LOCAL_MODULE_FILENAME := libprotobuf
LOCAL_SRC_FILES := libprotobuf.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/protocol.pb.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_SHARED_LIBRARIES := protobuf
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)我将非常感谢您的帮助:)
发布于 2012-09-16 23:48:07
您的日志显示您没有打开RTTI支持。有关说明,请参阅https://developer.android.com/ndk/guides/cpp-support#rtti:
要在ndk-build中跨整个应用程序启用
,请在Application.mk文件中添加以下行:
APP_CPPFLAGS := -frtti
要为单个ndk-build模块启用RTTI,请将以下行添加到其Android.mk中的给定模块:
LOCAL_CPP_FEATURES :=实时传输
或者,您可以使用:
LOCAL_CPPFLAGS := -frtti
https://stackoverflow.com/questions/12444865
复制相似问题