[英]Is it safe to link 2 different standard c++ library in one project
I'm building my iOS project with linking errors. 我正在使用链接错误构建我的iOS项目。 My project links against some third-party static libraries.
我的项目链接到一些第三方静态库。 They use different standard c++ library, one is
libstdc++
, the other is libc++
. 他们使用不同的标准c ++库,一个是
libstdc++
,另一个是libc++
。
Link against either one will cause the linking errors in other lib, so I link both of them in my target, the command line is -lstdc++ -lc++
. 链接任何一个都会导致其他lib中的链接错误,所以我在目标中链接它们,命令行是
-lstdc++ -lc++
。
Now it build successfully, but I wonder if it will cause some runtime error, can anybody explain about this ? 现在它成功构建,但我想知道它是否会导致一些运行时错误,有人能解释一下吗? Thanks in advance.
提前致谢。
No, it is not safe. 不,这不安全。 In fact, it is a direct violation of the One Definition Rule (ODR) .
实际上,它直接违反了One Definition Rule(ODR) 。 The ODR says, among other things, that you can have at most one definition of any non-inline function in an entire program.
除其他事项外,ODR表示在整个程序中最多只能有一个非内联函数的定义。 You will violate this rule by linking two different implementations of the standard library.
您将通过链接标准库的两个不同实现来违反此规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.