Linking error when I include dnn module in opencv 3.1.0

asked 2016-02-02 10:15:28 -0500

Nankong gravatar image

I post this question on stack overflow, but no one answer me. This is link: Question on Stackflow

I tried to use dnn module of Opencv 3.1.0 to do some object detection, which I follow tutorial here: Opencv dnn module tutorial

From my understanding, extra module, which contain dnn module, should be built with Opencv source. So I follow this tutorial: Build Opencv with Extra Modules

However, when I try to compile this simple code in Microsoft Visual Studio 2013,

#include <opencv2\dnn.hpp>
#include <opencv2\core.hpp>
using namespace cv;
using namespace cv::dnn;

void main() {


The result was:

1>------ Rebuild All started: Project: WithDnnModule, Configuration: Debug Win32 ------ 1> DnnTest.cpp 1>DnnTest.obj : error LNK2019: unresolved external symbol "private: void __thiscall cv::String::deallocate(void)" (?deallocate@String@cv@@AAEXXZ) referenced in function "public: __thiscall cv::String::~String(void)" (??1String@cv@@QAE@XZ) 1>C:\Rescourse\Project\opencvdnn\WithDnnModule\Debug\WithDnnModule.exe : fatal error LNK1120: 1 unresolved externals ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

If I don't include opencv2\dnn.hpp, I can build the code successfully.

Please help me out.

edit retag flag offensive close merge delete


additionally to opencv_dnn310d.lib you will need to link against opencv_core310d.lib and opencv_imgproc310.lib

berak gravatar imageberak ( 2016-02-02 10:20:04 -0500 )edit

Do you mean opencv_imgproc310.lib or opencv_imgproc310d.lib? If you mean the latter one, I'm sure I include opencv_core310d.lib and opencv_imgproc310d.lib.

Nankong gravatar imageNankong ( 2016-02-02 10:40:41 -0500 )edit

all with d for the debug build, without for the release one.

berak gravatar imageberak ( 2016-02-02 10:41:51 -0500 )edit

I can compile this without error:

#include <opencv2\highgui.hpp>
#include <opencv2\ximgproc.hpp>
#include <opencv2\core.hpp>
Nankong gravatar imageNankong ( 2016-02-02 10:42:08 -0500 )edit

I include all debug lib in my project.

Nankong gravatar imageNankong ( 2016-02-02 10:42:51 -0500 )edit

This is what I have in linker->input:

opencv_core310d.lib opencv_imgproc310d.lib opencv_dnn310d.lib opencv_aruco310d.lib opencv_bgsegm310d.lib opencv_bioinspired310d.lib opencv_calib3d310d.lib opencv_ccalib310d.lib opencv_dpm310d.lib opencv_face310d.lib opencv_features2d310d.lib opencv_flann310d.lib opencv_fuzzy310d.lib opencv_highgui310d.lib opencv_imgcodecs310d.lib opencv_line_descriptor310d.lib opencv_ml310d.lib opencv_objdetect310d.lib opencv_optflow310d.lib opencv_photo310d.lib opencv_plot310d.lib opencv_reg310d.lib opencv_rgbd310d.lib opencv_saliency310d.lib opencv_shape310d.lib opencv_stereo310d.lib opencv_stitching310d.lib opencv_structured_light310d.lib opencv_superres310d.lib opencv_surface_matching310d.lib opencv_text310d.lib opencv_ts310d.lib opencv_video310d.lib opencv_vid

Nankong gravatar imageNankong ( 2016-02-02 10:44:02 -0500 )edit