Skip to content
Advertisement

libopencv_core.so.2.4: error adding symbols: DSO missing from command line

I have installed OpenCV 3.3.0 to Ubuntu 16.04. Just want to compile this code.

#include <iostream>
using namespace std;
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cmath>

using namespace cv;

int main(int argc, char* argv[])
{
    try
    {
        int kernel_size = 3;
        cv::Mat src_host = cv::imread("crack2.jpg");
        cv::Mat gray_img, avg, kernel;
        cv::gpu::GpuMat dst, src;
        src.upload(src_host);

        cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);

        std::cout<< "Done!!!" <<std::endl;

    }catch(const cv::Exception& ex)
    {
        std::cout<<"Error: " << ex.what() << std::endl;
    }
    return 0;
}

g++ -o main gpu_thresh.cpp ‘pkg-config opencv –cflags –libs’ -lopencv_gpu -lopencv_core

g++ -L/usr/local/lib -o main gpu_thresh.cpp ‘pkg-config opencv –cflags –libs’ -lopencv_gpu -lopencv_core

I tried to compile it with these ways but still giving same warning and error.

/usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libopencv_gpu.so, may conflict with libopencv_core.so.3.3 /usr/bin/ld: /tmp/ccdhLGL0.o: undefined reference to symbol ‘_ZN2cv3gpu6GpuMat7releaseEv’ //usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

What should I do?

Advertisement

Answer

There’s no opencv2/gpu/gpu.hpp in OpenCV 3.3. If your code compiles then it means that you’ve both OpenCV 2.4 and 3.3 on your machine.

In OpenCV 3.3, include:

#include <opencv2/core/cuda.hpp>

and then use

cv::cuda::GpuMat img;

See details here.

Edit: I just noticed your compilation method. When using pkg-config opencv --cflags --libs, you don’t need to manually add the libopencv files anymore.

Just do: g++ -o main gpu_thresh.cpp 'pkg-config opencv --cflags --libs'

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement