静态和共享构建Android app_stl值之间的关系 [英] relation between app_stl values with static and shared build android

查看:268
本文介绍了静态和共享构建Android app_stl值之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在想,现在糊涂了。

在app_stl = stlport_static或stlport_shared在Application.mk文件设置和你正在试图建立共用和库的静态版本。是什么效果,为什么你会在你的Andr​​oid NDK应用程序中有一个特殊情况(见下文)?

让说我有

 案例1:APP_STL = stlport_static,包括$(BUILD_SHARED_LIBRARY)
案例2:APP_STL = stlport_static,包括$(BUILD_STATIC_LIBRARY)情形3:APP_STL = stlport_shared,包括$(BUILD_SHARED_LIBRARY)
情形4:APP_STL = stlport_shared,包括$(BUILD_STATIC_LIBRARY)

我明白的STLport和gnustl之间的differnce所以我擅长的那部分。


解决方案

  

1种情况:APP_STL = stlport_static,包括$(BUILD_SHARED_LIBRARY)结果
  案例2:APP_STL = stlport_static,包括$(BUILD_STATIC_LIBRARY)


这两种配置(STLport的静态链接)可以给你带来麻烦,如果你有这取决于STLport的两个或多个库。由于两个或更多的库周围的符号携带STLport的,你可能会违反一个定义规则

我相信这就是为什么 DOC / CPLUSPLUS-的support.html 有:


  

二。重要注意事项结果
  ...


  
  

二.3。静态运行时结果
  ...


  
  

请记住,一个给定的C的静态库变量++
  运行时只被链接到最佳的单个二进制
  条件。


  
  

这意味着,如果你的项目包括一个单一的共享
  图书馆,你可以反对,例如,stlport_static,一切链接
  将正常工作。


  
  

在另一方面,如果你在你的项目中的两个共享库
  (例如libfoo.so和libbar.so),这两者对同一静态链接
  运行时,他们每个人将包括运行时的code的副本
  其最终二进制图象。这是因为某些全局问题的
  使用/变量运行时内部提供被复制。


Been wondering and now confused.

When app_stl = stlport_static or stlport_shared is set in the Application.mk file and you are trying to build either shared and static version of the library. what is the effect,why would you have a specific case (see below) in your android ndk application ?

let say I have

Case1: APP_STL=stlport_static and include $(BUILD_SHARED_LIBRARY) 
Case2: APP_STL=stlport_static and include $(BUILD_STATIC_LIBRARY) 

Case3: APP_STL=stlport_shared and include $(BUILD_SHARED_LIBRARY) 
Case4: APP_STL=stlport_shared and include $(BUILD_STATIC_LIBRARY) 

I do understand the differnce between stlport and gnustl so I am good at that part.

解决方案

Case1: APP_STL=stlport_static and include $(BUILD_SHARED_LIBRARY)
Case2: APP_STL=stlport_static and include $(BUILD_STATIC_LIBRARY)

These two configurations (static linking of STLport) could get you in trouble if you have two or more libraries that depend upon STLport. Because two or more libraries are carrying around symbols for STLport, you will likely violate the One Definition Rule.

I believe that's why doc/CPLUSPLUS-SUPPORT.html has:

II. Important Considerations
...

II.3. Static runtimes
...

Please keep in mind that the static library variant of a given C++ runtime SHALL ONLY BE LINKED INTO A SINGLE BINARY for optimal conditions.

What this means is that if your project consists of a single shared library, you can link against, e.g., stlport_static, and everything will work correctly.

On the other hand, if you have two shared libraries in your project (e.g. libfoo.so and libbar.so) which both link against the same static runtime, each one of them will include a copy of the runtime's code in its final binary image. This is problematic because certain global variables used/provided internally by the runtime are duplicated.

这篇关于静态和共享构建Android app_stl值之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆