Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to configure opencv 3.0 with codeblock 13.12 - Win7

I new user of openCV and I am having troubles.

I am using 'codeblocks-13.12mingw-setup.exe', opencv 3.0rc1 and window 7 64 bits.

My steps until now was: - to extract the opencv to c:\opencv - to define the environment variables OPENCV_DIR and to add Path=%OPENCV_DIR%\bin;C:\Program Files (x86)\CodeBlocks\MinGW\bin; - I downloaded pkg-config and copied it to MinGW\bin directory

Now when I compile, the code below, everything works fine:

#include <iostream>
#include <opencv2/opencv.hpp>

int main()
{
    std::cout << "OpenCV Version: " << CV_VERSION << std::endl;


    return 0;
}

But, whe I compile this one:

#include <iostream>
#include "opencv2/core.hpp"

int main() {
    cv::Mat A(1000,1000,CV_64F);
    return 0; }

I receive this result:

C:\Users\user\Documents\CodeBlock\opencv02.o:opencv02.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d)||undefined reference to cv::fastFree(void*)'| C:\Users\user\Documents\CodeBlock\opencv02.o:opencv02.cpp:(.text$_ZN2cv3Mat6createEiii[__ZN2cv3Mat6createEiii]+0xb1)||undefined reference tocv::Mat::create(int, int const*, int)'| C:\Users\user\Documents\CodeBlock\opencv02.o:opencv02.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x30)||undefined reference to __atomic_fetch_add_4'| C:\Users\user\Documents\CodeBlock\opencv02.o:opencv02.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x49)||undefined reference tocv::Mat::deallocate()'| ||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

or this one:

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

using namespace cv;
using namespace std;

int main()
{
    Mat image;
    image = imread("imagem.jpg", CV_LOAD_IMAGE_COLOR);

    if(! image.data )
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );
    imshow( "Display window", image );

    waitKey(0);
    return 0;
}

I receive:

C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp|| undefined reference to cv::imread(cv::String const&, int)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp|| undefined reference to cv::namedWindow(cv::String const&, int)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp|| undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp|| undefined reference to cv::waitKey(int)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x3c)||undefined reference to cv::String::allocate(unsigned int)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv6StringD1Ev[__ZN2cv6StringD1Ev]+0xf)||undefined reference to cv::String::deallocate()'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d)||undefined reference to cv::fastFree(void*)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv3MataSERKS0_[__ZN2cv3MataSERKS0_]+0xf8)||undefined reference to cv::Mat::copySize(cv::Mat const&)'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x30)||undefined reference to __atomic_fetch_add_4'| C:\Users\user\Documents\CodeBlock\opencv03.o:opencv03.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x49)||undefined reference tocv::Mat::deallocate()'| ||=== Build failed: 10 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I already tried to add "pkg-config --cfalgs --libs opencv" to Settings->Compiler->Linker Settings->Other Linker Options, but it does not worked. In this case I receive this message:

pkg-config||No such file or directory| opencv||No such file or directory| |=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|