Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

dnn unresolved external symbol during linking

I am using OpenCV 4.0.0-pre in my C++ project, Visual Studio 2015 Win32. I have an issue when linking to opencv dnn.

I have 2 copies of opencv on my computer. They were both from github, in version 4.0.0-pre. But I got them a few weeks apart so the source code had a few different commits.

I used one opencv (opencvA) to test my project. It was built locally. My project was to include and link opencvA. Every thing worked fine.

Then I tried to use the other opencv (opencvB) to work my project (I could have stick to opencvA, but I did a new download from github instead). It was built remotely by Jenkins, using the same version of Visual Studio and same configuration. All header files, libs and dlls were deployed on my computer. When I tried link opencvB, it gave me errors:

error LNK2001: unresolved external symbol "class cv::dnn::dnn4_v20180917::Net __cdecl cv::dnn::dnn4_v20180917::readNet(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?readNet@dnn4_v20180917@dnn@cv@@YA?AVNet@123@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z)
error LNK2001: unresolved external symbol "public: __int64 __thiscall cv::dnn::dnn4_v20180917::Net::getPerfProfile(class std::vector<double,class std::allocator<double> > &)" (?getPerfProfile@Net@dnn4_v20180917@dnn@cv@@QAE_JAAV?$vector@NV?$allocator@N@std@@@std@@@Z)
error LNK2001: unresolved external symbol "public: void __thiscall cv::dnn::dnn4_v20180917::Net::setInput(class cv::_InputArray const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double,class cv::Scalar_<double> const &)" (?setInput@Net@dnn4_v20180917@dnn@cv@@QAEXABV_InputArray@4@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@NABV?$Scalar_@N@4@@Z)
error LNK2001: unresolved external symbol "public: class cv::Mat __thiscall cv::dnn::dnn4_v20180917::Net::forward(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?forward@Net@dnn4_v20180917@dnn@cv@@QAE?AVMat@4@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
error LNK2001: unresolved external symbol "public: bool __thiscall cv::dnn::dnn4_v20180917::Net::empty(void)const " (?empty@Net@dnn4_v20180917@dnn@cv@@QBE_NXZ)
error LNK2001: unresolved external symbol "public: __thiscall cv::dnn::dnn4_v20180917::Net::~Net(void)" (??1Net@dnn4_v20180917@dnn@cv@@QAE@XZ)
error LNK2001: unresolved external symbol "public: __thiscall cv::dnn::dnn4_v20180917::Net::Net(void)" (??0Net@dnn4_v20180917@dnn@cv@@QAE@XZ)
error LNK2001: unresolved external symbol "class cv::Mat __cdecl cv::dnn::dnn4_v20180917::blobFromImage(class cv::_InputArray const &,double,class cv::Size_<int> const &,class cv::Scalar_<double> const &,bool,bool,int)" (?blobFromImage@dnn4_v20180917@dnn@cv@@YA?AVMat@3@ABV_InputArray@3@NABV?$Size_@H@3@ABV?$Scalar_@N@3@_N3H@Z)

The error only happens to DNN module. The Core module was linked without problem. When I dump the DNN lib file from opencvB, function signatures are such as:

class cv::dnn::dnn4_v20180903::Net __cdecl cv::dnn::dnn4_v20180903::readNet(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<unsigned char,class std::allocator<unsigned char> > const &,class std::vector<unsigned char,class std::allocator<unsigned char> > const &)

The timestamp, 20180903 and 20180917, mismatch. The functions from opencvB have signatures with 20180903, but my project was trying to find signatures with 20180917. I checked my include path. My project include opencvB, not opencvA, so I should be using the correct header files. I also cleaned old object files in my project.

Any ideas what is causing the issue and how to fix it? Also could anyone explain why timestamp is append to function signatures in the DNN module? Thanks.

dnn unresolved external symbol during linking

I am using OpenCV 4.0.0-pre in my C++ project, Visual Studio 2015 Win32. I have an issue when linking to opencv dnn.

I have 2 copies of opencv on my computer. They were both from github, in version 4.0.0-pre. But I got them a few weeks apart so the source code had a few different commits.

I used one opencv (opencvA) to test my project. It was built locally. My project was to include and link opencvA. Every thing worked fine.

Then I tried to use the other opencv (opencvB) to work my project (I could have stick to opencvA, but I did a new download from github instead). It was built remotely by Jenkins, using the same version of Visual Studio and same configuration. All header files, libs and dlls were deployed on my computer. When I tried link opencvB, it gave me errors:errors such as:

error LNK2001: unresolved external symbol "class cv::dnn::dnn4_v20180917::Net __cdecl cv::dnn::dnn4_v20180917::readNet(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?readNet@dnn4_v20180917@dnn@cv@@YA?AVNet@123@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z)
error LNK2001: unresolved external symbol "public: __int64 __thiscall cv::dnn::dnn4_v20180917::Net::getPerfProfile(class std::vector<double,class std::allocator<double> > &)" (?getPerfProfile@Net@dnn4_v20180917@dnn@cv@@QAE_JAAV?$vector@NV?$allocator@N@std@@@std@@@Z)
error LNK2001: unresolved external symbol "public: void __thiscall cv::dnn::dnn4_v20180917::Net::setInput(class cv::_InputArray const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double,class cv::Scalar_<double> const &)" (?setInput@Net@dnn4_v20180917@dnn@cv@@QAEXABV_InputArray@4@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@NABV?$Scalar_@N@4@@Z)
error LNK2001: unresolved external symbol "public: class cv::Mat __thiscall cv::dnn::dnn4_v20180917::Net::forward(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?forward@Net@dnn4_v20180917@dnn@cv@@QAE?AVMat@4@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
error LNK2001: unresolved external symbol "public: bool __thiscall cv::dnn::dnn4_v20180917::Net::empty(void)const " (?empty@Net@dnn4_v20180917@dnn@cv@@QBE_NXZ)
error LNK2001: unresolved external symbol "public: __thiscall cv::dnn::dnn4_v20180917::Net::~Net(void)" (??1Net@dnn4_v20180917@dnn@cv@@QAE@XZ)
error LNK2001: unresolved external symbol "public: __thiscall cv::dnn::dnn4_v20180917::Net::Net(void)" (??0Net@dnn4_v20180917@dnn@cv@@QAE@XZ)
error LNK2001: unresolved external symbol "class cv::Mat __cdecl cv::dnn::dnn4_v20180917::blobFromImage(class cv::_InputArray const &,double,class cv::Size_<int> const &,class cv::Scalar_<double> const &,bool,bool,int)" (?blobFromImage@dnn4_v20180917@dnn@cv@@YA?AVMat@3@ABV_InputArray@3@NABV?$Size_@H@3@ABV?$Scalar_@N@3@_N3H@Z)

The error only happens to DNN module. The Core module was linked without problem. When I dump the DNN lib file from opencvB, function signatures are such as:

class cv::dnn::dnn4_v20180903::Net __cdecl cv::dnn::dnn4_v20180903::readNet(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<unsigned char,class std::allocator<unsigned char> > const &,class std::vector<unsigned char,class std::allocator<unsigned char> > const &)

The timestamp, 20180903 and 20180917, mismatch. The functions from opencvB have signatures with 20180903, but my project was trying to find signatures with 20180917. I checked my include path. My project include opencvB, not opencvA, so I should be using the correct header files. I also cleaned old object files in my project.

Any ideas what is causing the issue and how to fix it? Also could anyone explain why timestamp is append to function signatures in the DNN module? Thanks.