首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NDK。Protobuf库链接

NDK。Protobuf库链接
EN

Stack Overflow用户
提问于 2012-09-16 14:29:46
回答 1查看 2.8K关注 0票数 1

日安。我用ndk编译了protobuf 2.4.1库。我从那篇文章中摘录的脚本:How to build protocol buffer by Android NDK

但是当我尝试将我的库链接到测试cocos2d-x项目时,我得到了下一个错误:

代码语言:javascript
复制
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的源代码

代码语言:javascript
复制
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)

我将非常感谢您的帮助:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12444865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档