How to get Debug Libraries from Source code on Linux

asked 2019-01-19 16:15:23 -0500

Hello everyone

I am trying to build my first OpenCV applications and I have followed the installation instruction on the OpenCV website for Linux. I can build and tun the first example First Example. The problem occurs when I try to debug this same application using the Debugger in QtCreator. Now I probably have to link the debug libraries for OpenCV when using the debugger, but I'm not sure how I can get these from the source code. I tried compiling the source files using the following commands:

cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

And then running the following commands in the project directory of my first example application:

cmake
make

The CMAKE code I'm using is the following:

cmake_minimum_required(VERSION 2.8)

project(opencv_0)
find_package(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(opencv_0 debug ${OpenCV_LIBS})

And the C++ code of the example:

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc,char** argv)
{
    Mat image;
    image=imread("lenna.jpg",1);
    if(!image.data){
        printf("Could not read picture!\n");
        return 1;
    }
    namedWindow("Display Image",WINDOW_AUTOSIZE);
    imshow("Display Image",image);

    waitKey(0);

    return 0;
}

I'm not really sure what I need to change to be able to use the debugger?

edit retag flag offensive close merge delete