What happend to the String class defined in opencv2/core/cvstd.hpp?

I see in the docs that until version 3.4.14 there was a string class defined in cvstd.hpp which was apparently removed starting with version 4.0.0. Does someone know why and where this class is defined now?

I’m asking this because I get a linker error
(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to cv::String::deallocate()'
when I try to include OpenCV static libraries in my project and I’m wondering which file I should include for the linker so the symbol can be resolved.

you get a linker error, when doing what ? using which actual opencv version ?

with static linking, order of libs matters(and will produce errors like above, if you get it wrong !). so please show your cmdline

(and the cv::String class simply got replaced by std::string in recent opencv)

Thanks for your answer. My goal is to wrap OpenCV in another library, let’s call it libdetector.

The wrapper code looks like this (it doesn’t do anything useful yet, just for illustration)


#include "detector.hh"
#include <string>
#include <vector>
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"

namespace detector {

Detector::Detector(const std::string& filepath) : filepath(filepath) {}
std::vector<float> Detector::detect(float similarityThreshold) {
  cv::Mat new_img = cv::Mat::zeros(1, 49, CV_64FC1);
  std::vector<float> vec{1.0, 1.0, 1.0};
  return vec;

}  // namespace detector


#ifndef DETECTOR_H
#define DETECTOR_H
#include <string>
#include <vector>
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"
namespace detector {
class Detector {
  std::string filepath;
  Detector(const std::string &filepath);
  std::vector<float> detect(float similarityThreshold = 0.7);

}  // namespace detector


If I now compile this to a shared library with

g++ -Wl,--no-undefined -fPIC -shared -o libdetector.so detector.cc opencv/lib/libopencv_highgui.a opencv/lib/libopencv_videoio.a opencv/lib/libopencv_imgproc.a opencv/lib/libopencv_core.a opencv/3rdparty/lib/*.a opencv/3rdparty/ippicv/ippicv_lnx/icv/lib/intel64/libippicv.a -ldl -lpthread -lz

I get undefined reference to cv::String::deallocate()

If I’d just add the definition

namespace cv {
void String::deallocate(){};

to my detector.cc source, it works as expected. So for some reason the linker can’t find the cv::String::deallocate() symbol in the OpenCV libraries.