LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-19-2019, 03:58 PM   #1
Mantabit
LQ Newbie
 
Registered: Jan 2019
Location: Europe
Distribution: Ubuntu
Posts: 9

Rep: Reputation: Disabled
How to use CMAKE to get debug libraries for OpenCV


Hello everyone

I am new to using OpenCV on Linux and I have run into the following problem: I am trying to write some first C++ applications using OpenCV. I downloaded the source code (v.3.4.5) for OpenCV from their webpage. Then I compiled the source code using CMAKE, make and make install. So far everything went okay and I can compile and run the first example:https://docs.opencv.org/3.2.0/db/df5...gcc_cmake.html

The problem is that when I try to compile the application in Debug mode using QtCreator, the same code as in the example won't work. Now I assume that is because I need to link the debug libraries for OpenCV when debugging, however, I'm not sure how I can get the debug libraries from the source code. So far I basically tried the following commands in the source-code

Code:
cmake -D WITH_QT=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
As far as I know, the debug libraries should have the same name as the release libraries but with a "d" at the end, so for example "libopencv_core.so" should be called "libopencv_cored.so". I tried searching for "libopencv_cored.so" using:

Code:
sudo find / -name libopencv_cored.so
but such a file doesn't exist anywhere on the system so I guess my compilation does not create the required debug libraries? So my question is basically how I can compile the debug libraries from the source code?

The CMAKE code for my project currently looks like this:

Code:
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 looks like this:

Code:
#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;
}

Last edited by Mantabit; 01-19-2019 at 04:04 PM.
 
Old 01-22-2019, 04:05 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
The cmake target_link_libraries and Transitive Usage Requirements reference pages probably have the information you are missing.

I understand just enough cmake to build projects which use it, but have not used it as the build environment for any of my own, so cannot offer much more help.

Look over the above links and you should be able to resolve your issue.

Good luck!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware-current: /usr/share/cmake and /usr/share/cmake-3.3 directories igor29768 Slackware 1 11-07-2015 12:37 AM
got a problem install opencv when i run make command after cmake compiling ninianne Linux - Software 3 04-10-2013 10:56 PM
CMake Strange "Install" behaviour with home-grown software [Linux x86_64, CMake 2.8] ajschaeffer Programming 0 10-24-2011 03:21 AM
OpenCV - Pixel format of incoming image is unsupported by OpenCV golmschenk Programming 1 04-01-2011 12:32 PM
cmake: Using find_package(Boost) when FindBoost.cmake is not in the default location damien_d Programming 3 10-27-2010 03:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration