error in command line

asked 2019-08-12 00:51:57 -0500

Hongs gravatar image

updated 2019-08-12 00:55:27 -0500

berak gravatar image

my cord

// include the librealsense C++ header file
#include <librealsense2/rs.hpp>

// include OpenCV header file
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main()
{
    //Contruct a pipeline which abstracts the device
    rs2::pipeline pipe;

    //Create a configuration for configuring the pipeline with a non default profile
    rs2::config cfg;

    //Add desired streams to configuration
    cfg.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_BGR8, 30);

    //Instruct pipeline to start streaming with the requested configuration
    pipe.start(cfg);

    // Camera warmup - dropping several first frames to let auto-exposure stabilize
    rs2::frameset frames;
    for(int i = 0; i < 30; i++)
    {
        //Wait for all configured streams to produce a frame
        frames = pipe.wait_for_frames();
    }

    //Get each frame
    rs2::frame color_frame = frames.get_color_frame();

    // Creating OpenCV Matrix from a color image
    Mat color(Size(640, 480), CV_8UC3, (void*)color_frame.get_data(), Mat::AUTO_STEP);

    // Display in a GUI
    namedWindow("Display Image", WINDOW_AUTOSIZE );
    imshow("Display Image", color);

    waitKey(0);

    return 0;
}

and my command

g++ -std=c++11 BGR_sample.cpp -lrealsense2 -lopencv_core -lopencv_highgui -o BGR && ./BGR

but error

/usr/bin/ld: /tmp/ccOsYVa0.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
//usr/local/lib/libopencv_core.so.3.4: error adding symbols: DSO missing from command line
edit retag flag offensive close merge delete

Comments

does /usr/local/lib/libopencv_core.so.3.4 exist ? why is there a double // at the beginning ?

berak gravatar imageberak ( 2019-08-12 00:57:23 -0500 )edit

yes that file exist and i don't know about //

Hongs gravatar imageHongs ( 2019-08-12 01:37:35 -0500 )edit

@berak and i changed g++ to gcc error code changed to this

/usr/bin/ld: /tmp/ccvXuxi2.o: undefined reference to symbol '_ZN2cv6String10deallocateEv' //usr/local/lib/libopencv_core.so.3.4: error adding symbols: DSO missing from command line

Hongs gravatar imageHongs ( 2019-08-12 02:12:00 -0500 )edit

Maybe there is a conflict of versions of opencv. Do you have multiple versions installed? Try running: sudo apt-get autoremove libopencv-dev

savailonei gravatar imagesavailonei ( 2019-08-12 02:19:23 -0500 )edit
1

@savailonei i tried but it seems Package 'libopencv-dev' is not installed, so not removed

Hongs gravatar imageHongs ( 2019-08-12 02:23:21 -0500 )edit

so, what did you install, and where ? from where, even ? os / opencv / g++ version ?

berak gravatar imageberak ( 2019-08-12 02:36:43 -0500 )edit

Try running more general: sudo apt-get autoremove

savailonei gravatar imagesavailonei ( 2019-08-12 02:39:40 -0500 )edit

@berak ah OS is ubuntu 16.04LTS, g++ version 5.5.0, opencv 3.4.0 and i don't know mean that where from where

Hongs gravatar imageHongs ( 2019-08-12 02:46:21 -0500 )edit

@savailonei i also tried but it was same. 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Hongs gravatar imageHongs ( 2019-08-12 02:49:05 -0500 )edit

from where

opencv does not maintain any linux binaries or packages.

did you build it from src ? why such an outdated version ? (3.4.7 is current)

berak gravatar imageberak ( 2019-08-12 02:50:00 -0500 )edit