Ask Your Question
0

Why is it safe to pass cv::String& accross DLL boundary?

asked 2019-06-10 03:22:05 -0600

I've recently learnt that it's highly not recommended to pass any STL object across the shared library boundary, because their ABI is not standardized, and so if the library and the code that uses it are compiled with different compilers, the STL objects could be perceived differently (different byte order etc).

Some functions in OpenCV take const cv::String& as an argument (imread(), imwrite() etc), and here I see that cv::String is just a typedef to std::string.

So why aren't there any problems with using OpenCV as a shared library?

edit retag flag offensive close merge delete

Comments

which opencv version are you talking about ?

please be very careful here, since opencv4 switched back to std::string under the hood

berak gravatar imageberak ( 2019-06-10 04:50:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-06-10 04:58:35 -0600

Yeah, I relied on the docs for v4.1.0. And since cv::String is std::string under the hood, I'm confused how can it be passed safely when OpenCV is linked dynamically.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-06-10 03:09:54 -0600

Seen: 179 times

Last updated: Jun 10 '19