Why is it safe to pass cv::String& accross DLL boundary?
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?
which opencv version are you talking about ?
please be very careful here, since opencv4 switched back to std::string under the hood