0
votes

Can you please help me with the following issue?

I am running Code::Blocks 13.12 on 64-bit Debian Linux. I am new user of this IDE. When I create new OpenCV project in Code::Blocks and set proper compiler flags and linker flags, i.e. by putting ...

  • `pkg-config opencv --cflags` into Settings > Compiler > Compiler settings tab > Other options tab
  • `pkg-config opencv --libs` into Settings > Compiler > Linker settings tab > Other linker options
  • /usr/include/, /usr/include/opencv/, /usr/include/opencv2/ paths into Settings > Compiler > Search directories tab > Compiler tab,

compilation of the project is just fine. The only thing that doesn't work is code completion for OpenCV functions.

I have following code in main.cpp. When I click right mouse button over the imread function and choose Find declaration of: 'imread' menu option, an alert with Not found: imread message is raised. But doing same thing on STD's cerr works as expected.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main( int argc, char * argv[] ) {

  Mat img = imread( "lena.jpg", CV_LOAD_IMAGE_COLOR );

  if ( img.empty() ) {
    cerr << "Unable to load the Lena image!" << endl;
    return -1;
  }

  namedWindow( "lena", CV_WINDOW_AUTOSIZE );
  imshow( "lena", img );

  waitKey( 0 );
  return 0;
}

When I choose the Symbols tab on the left vertical bar, I can see the cv namespace there but it seems empty. There are no subitems and it can not be expanded as the std namespace.

Am I doing something wrong? How should I persuade the Code::Blocks to parse also OpenCV's headers? Just restarting/reopenning IDE/project doesn't work. :-)

Thank you very much for your replies.

1
I am an experienced CB user and I'm damned if I can get it to work either in 13.12. Another C++ IDE I use on Linux is CodeLite: here, as long as the opencv headers are installed then code-completion, find declaration etc. for the opencv symbols works without do anything additional to the project or compiler config. - Mike Kinghan
thanks for your confirmation, I'll try CodeLite then ... - Michal Wirth

1 Answers

0
votes

Using Code::Blocks 10.05 on Ubuntu 12.04 I am doing this way, you can try this.

Go to Setting->Compiler and Debugger setting

  • In Search directories tab click on Compiler sub-tab add OpenCV include path,

    usually, /usr/local/include

  • Click on Linker sub-tab and add opencv bin directory

    Usually /usr/local/bin

  • Now go to Linker setting tab and on Other linker option add link libraries

    like,

    -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab