简体   繁体   English

STLport和Android NDK-以静态方式加载的STLport,Linux / gcc ld报告“多个定义”

[英]STLport and Android NDK - STLport loaded as static, Linux/gcc ld reports “multiple definitions”

I've looked thru a lot of material on Android NDK and STLport. 我在Android NDK和STLport上浏览了很多资料。 I have complex app, java+native code, which loads STLport (a c++ standard library port). 我有一个复杂的应用程序,java + native代码,它加载STLport(C ++标准库端口)。 The original codebase had "APP_STL := stlport_static" in the Application.mk in the project's "jni" subdir. 原始代码库在项目的“ jni”子目录中的Application.mk中具有“ APP_STL:= stlport_static”。 Causes ld to load the lib static. 使ld加载lib静态文件。 This caused many compile failures, in current SDK/NDK. 在当前的SDK / NDK中,这导致了许多编译失败。

Tried to load as a dynamic lib, as per a suggestion. 根据建议尝试加载为动态库。 (In "../jni/Application.mk", set "APP_STL := stlport_shared") With this, I get a clean compile, and load, and the app runs flawlessly on the Android armeabi-v7a emulator, if I disable checkJNI on the "dalvik" virtual machine. (在“ ../jni/Application.mk”中,设置“ APP_STL:= stlport_shared”)这样,我可以进行干净的编译和加载,并且如果我禁用checkJNI, 该应用程序可以在Android armeabi-v7a模拟器上完美运行。在“ dalvik”虚拟机上。

But once I enable checkJNI, I get an "unsatisfiedLinkError" on the libapplication.so, which looks like it might result from STLport being dynamically loaded. 但是,一旦启用checkJNI,我就会在libapplication.so上收到一个“ unsatisfiedLinkError”,看起来好像是动态加载STLport导致的。 So, I want to load STLport in static mode (logcat reports this after several other libs successfully loaded). 因此,我想以静态模式加载STLport(在成功加载其他几个库之后,logcat报告此问题)。 During the build, compile is ok, but I am getting two multiple definition errors, specifically: "multiple definition of 'vtable for std::bad_exception' " and of 'std::exception::~exception()'. 在构建过程中,编译是可以的,但是我遇到了两个多重定义错误,特别是:“'vtable for std :: bad_exception'的多个定义”和'std :: exception :: ~~ exception()'的多重定义。 (I have also tried using "gnustl_static"). (我也尝试过使用“ gnustl_static”)。

I am using gcc version 4.3.0 and make version 3.81, command line mode, and small wrapper around build-ndk, for android ndk-r9c, with a build target version of android-8, "ant" to build the .apk file, and so on. 我正在使用gcc版本4.3.0,并使版本3.81,命令行模式和围绕build-ndk的小型包装器(适用于android ndk-r9c)以及android-8的构建目标版本为“ .ant”来构建.apk文件, 等等。

Someone who has more familiarity with Android than me (I am a complete noob) might have seen this before. 可能比我更熟悉Android(我是一个完全菜鸟)的人。 If so, please advise. 如果是这样,请告知。 Thanx. 感谢名单。 - Rus -罗斯

It's definitely possible to use stlport_static with NDK r9c. 这是绝对有可能使用stlport_static与NDK R9C。 What object files are mentioned with multiple definition errors? 提到哪些目标文件有多个定义错误? Maybe, you are using some prebuilt libraries? 也许您正在使用一些预建的库? Maybe, the gcc version 4.3 is problematic? 也许gcc版本4.3有问题? Why don't you use the default (gcc 4.8)? 为什么不使用默认值(gcc 4.8)?

With that, the NDK document explicitly encourages use of shared STL, but you must not forget to call System.loadLibrary() in correct order: 因此, NDK文档明确鼓励使用共享STL,但您一定不要忘记以正确的顺序调用System.loadLibrary()

System.loadLibrary("stlport_shared");
System.loadLibrary("Rusfuture");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM