lscodex
lscodex

Reputation: 180

libopencv_highgui.so.3.4: cannot open shared object file: No such file or directory in the eclipse ide for cross compiler

I have stucked a problem. I develop cross-compile for the embedded system. I built the opencv for arm_linux-gnueabihf.

My ubuntu version is 18.04.2 x86_64 5.3.0.51-generic.

The problem that

libopencv_highgui.so.3.4: cannot open shared object file: No such file or directory I build the project success but when I run the project, I get the problem

this my code

#include <iostream>
#include <stdio.h>
#include <cv.h>
#include <opencv2/videoio.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;

int main(int, char**){
    Mat frame;
    VideoCapture cap;
    int deviceId = 0;
    int apiId = cv::CAP_ANY;
    cap.open(deviceId,apiId);
    if (!cap.isOpened()){
        cerr<<"Error! Unable to camera\n";
        return -1;
    }
    for(;;){
        // read frame
        cap.read(frame);
        if (frame.empty()){
            cerr <<" ERROR ! black frame grabbed ! \n";
            break;
        }
        imshow("Live",frame);
        if (waitKey(5) >= 0){
            break;
        }
    }
    return 0;
}

I checked the library as follows:

sudo find / -name "libopencv_highgui.so.3.4"

the command returned as follows

/usr/local/lib/libopencv_highgui.so.3.4
/usr/local/lib/libopencv_highgui.so.3.4.4
/usr/local/include/lib/libopencv_highgui.so.3.4
/usr/local/include/lib/libopencv_highgui.so.3.4.4

I created a file in /etc/ld.so.conf.d/opencv.conf that contain

/usr/local/lib
/usr/local/include

then I run the command that sudo ldconfig -v, and it returned as follow

/sbin/ldconfig.real: /usr/local/lib/libopencv_highgui.so.3.4.4 is for unknown machine 40.

/sbin/ldconfig.real: /usr/local/lib/libopencv_imgproc.so is for unknown machine 40.

/sbin/ldconfig.real: /usr/local/lib/libopencv_xfeatures2d.so is for unknown machine 40.

/sbin/ldconfig.real: /usr/local/lib/libopencv_bgsegm.so.3.4.4 is for unknown machine 40.

/sbin/ldconfig.real: /usr/local/lib/libopencv_objdetect.so.3.4 is for unknown machine 40.

and also other opencv's libraries.

I configured setting of the eclipse for the libraries as follows:

the "Includes" folder that in cross G++ Compiler Includes

"Libraries" folder that in cross G++ Linker Libraries

Finally, I added the LD_LIBRARY_PATH in debug of the eclipse setting Path Conf.

I tried sudo apt update and sudo apt upgrade commands,but I still getting the error.

Does any one have any advice ?

Upvotes: 0

Views: 6781

Answers (1)

lscodex
lscodex

Reputation: 180

the solution is add the "/usr/local/lib" to LD_LIBRARY_PATH in environment. mine is LD_LIBRARY_PATH /usr/arm-linux-gnueabihf/lib/:usr/local/lib/

Upvotes: 2

Related Questions