0
votes

I'm trying to link opencv 2.4.13 to a visual studio project. I have the .lib and .dll files in subfolders of the projects. I added the relative paths to the configuration. But I still get linking errors. My goal is to make the project portable: fi I take the directory to another machine, I will be able to run without installing opencv separately on the machine.

What I added:

  • lib subdirectory to Additional Library Directories
  • the include directories to the Additional Include Directories
  • the .dll in Linker -> Input -> Additional Dependencies

Here is an example of these errors:

LNK2019 unresolved external symbol __wcsdup_dbg referenced in function __Getctype   
LNK2001 unresolved external symbol __wcsdup_dbg 
LNK2019 unresolved external symbol __realloc_dbg referenced in function "private: static void __cdecl std::locale::_Locimp::_Locimp_Addfac(class std::locale::_Locimp *,class std::locale::facet *,unsigned int)" (?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z)

Any Ideas?

2

2 Answers

0
votes

Make sure all your libraries are built with the same debugging configuration - that is, if you're building a DEBUG version of your project, you need to link it against the DEBUG libraries, and if you're building a RELEASE version of your project, you need to link it against the RELEASE libraries.

Likewise, you need to make sure everything else is compatible in your build options - e.g. if the libraries are built with /MT enabled, you have to also build your application with /MT enabled. Same with calling convention (/Gd, /Gr, /Gz), 32- or 64-bit, etc.

The linker errors you are getting reference _dbg symbols, which would seem to imply that you have a DEBUG/RELEASE inconsistency somewhere.

0
votes

I finally figured it out using an answer on this question: Question: OpenCV - missing dlls?

I just added the path of my dlls to Debugging Environment: Project –> Properties –> Configuration Properties –> Debugging –> Environment –> add dlls' paths here, with the following syntax:

  • For example, to prepend C:\Windows\Temp to the PATH: PATH=C:\WINDOWS\Temp;%PATH%
  • Similarly, to append $(SolutionDir)\DLLS to the PATH: PATH=%PATH%;$(SolutionDir)\DLLS