cvstd.hpp:622: undefined reference to `cv::String::allocate(unsigned long long)

asked 2018-06-02 22:33:22 -0500

Bezzzo gravatar image

Hi, i've recently installed opencv 3.4, built it and added the includes to eclipse, library path and linked the libraries as well.

I am getting a build error and i'm not sure what to do next, i cant find any solutions online that can help me. It's possible i have maybe setup something wrong?

Error from eclipse:

13:23:32 * Incremental Build of configuration Debug for project Vision * Info: Internal Builder is used for build g++ "-LC:\cygwin64\lib" -o Vision.exe main.o -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_highgui -lopencv_core main.o: In function cv::String::String(char const*)': C:/Users/*****/Documents/opencv/build/include/opencv2/core/cvstd.hpp:622: undefined reference tocv::String::allocate(unsigned long long)' collect2.exe: error: ld returned 1 exit status 13:23:32 Build Finished (took 316ms)

Code is take from opencv exmple:

#include "opencv2/opencv.hpp"
#include "opencv2/core/cvstd.hpp"
using namespace cv;

int main(int, char**)
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

        Mat frame;
        cap >> frame;         // get a new frame from camera
        imshow("Video", frame);

        // Press 'c' to escape
        if(waitKey(30) == 'c') break;
    return 0;

If i remove imshow("Video", frame); it removes the error.

Any help or a point in the right direction would really very much be appreciated.

Thank you very much

edit retag flag offensive close merge delete


the opencv libs probably are NOT in C:\cygwin64\lib. also, if you arre using mingw, you cannont use the prebuild opencv libs, but have to build from src , locally. then they would be in opencv/build/install/x64/mingw/lib

berak gravatar imageberak ( 2018-06-03 00:01:05 -0500 )edit

I originally had my library set to opencv/build/install/x64/mingw/lib but i get an error during build for each linked library: cannot find -lopencv_video; cannot find -lopencv_videoio etc. I installed opencv libraries with cygwin and pointed the library path to there and that solved my problem, though now it get the error as mention above.

Bezzzo gravatar imageBezzzo ( 2018-06-03 00:32:27 -0500 )edit

again, you have to BUILD the libs first, using cmake.

oh, and mingw has versioned libs, like -lopencv_core341

berak gravatar imageberak ( 2018-06-03 00:37:16 -0500 )edit

"Hi, i've recently installed opencv 3.4, built it" Mate, i've built it with cmake, its done, all built and indexed, library path added and linked.

Bezzzo gravatar imageBezzzo ( 2018-06-03 00:49:44 -0500 )edit

ok, still you have to add those version numbers,when linking.

berak gravatar imageberak ( 2018-06-03 00:55:43 -0500 )edit

I did add the version number was still the same, so i ended up going though cygwin. Must something really silly i haven't done properly because it's just not making sense to me. Thanks for your help anyway, but this is really doing my head in. I've decided im going to try and install a opencv on a linux virtual machine and start from scratch.

Bezzzo gravatar imageBezzzo ( 2018-06-03 01:05:41 -0500 )edit

no idea about cygwin, sorry (it's infamously messing with pathes)

maybe not give up early, but try to get all those "helpful" tools like cygwin & eclipse out of your way, try to compile something simple on the cmdline like:

g++ -Lopencv/build/install/x64/mingw/lib -Iopencv/build/install/include -o Vision.exe main.o -lopencv_video341 -lopencv_videoio341 -lopencv_imgproc341 -lopencv_highgui341 -lopencv_core341
berak gravatar imageberak ( 2018-06-03 01:08:04 -0500 )edit

I just tried through cmd and got fatal error: opencv2/opencv.hpp No such file or directory #include "opencv2/opencv.hpp". Not sure why, i've triple checked the paths, file is there. And there is no error shown in eclipse at all with any includes.

Bezzzo gravatar imageBezzzo ( 2018-06-03 01:35:42 -0500 )edit