Is it safe to link 2 different C ++ standard libraries in the same project?

I am creating an iOS project with linking errors. My project is linked with some 3rd party static libraries. They use a different C ++ standard library, one is libstdc++

, the other is libc++

.

Linking one of these will result in linking errors in the other library, so I link both of them to my target, the command line string -lstdc++ -lc++

.

Now it works successfully, but I am wondering if it might cause some runtime error, can someone please explain about this? Thanks in advance.

+3


source to share


1 answer


No, it is not safe. In fact, this is a direct violation of the 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. You break this rule by linking two different standard library implementations.



+4


source







All Articles