Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

c++ - Type undefined reference to `cv::fastFree(void*)'

I started the tutorial for opencv 2.4.7 on Win8, latest MinGW, and Eclipse Kepler R1, CDT. C++ Compiler includes are referencing to [path-to-opencv]open247uildinclude.

in the MinGW C++ Linker I add the library path [path-to-opencv]open247uildx64vc11lib. The vc11 directory contains libraries for VisualStudio from what I've read. Is that still okay to compile them with MinGW?

I added the core and highgui library for this sample (I don't think we need more than those).

However, for this simple idle code below, I provoke the following compilation error.

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

using namespace cv;
using namespace std;

int main(){
    Mat image;
}

The error on compilation is:

Description Resource    Path    Location    Type
undefined reference to `cv::fastFree(void*)'    FirstOpenCV     line 278, external location: C:UsersJohnDocumentsSoftwareopencv247uildincludeopencv2coremat.hpp  C/C++ Problem

What's the reason for this?

If I add

namedWindow("testWindow", 1);

I even get this error

Description Resource    Path    Location    Type
undefined reference to `cv::namedWindow(std::string const&, int)'   main.cpp    /FirstOpenCV/src    line 23 C/C++ Problem
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Have you link correctly your library?

-lopencv_core
-lopencv_highgui
-L<opencv_library_path>

The libraries have to be specified after the source file on the compiler/linker command line. (The linker keeps track of unresolved symbols, and resolves them via later command-line arguments.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...