0

I am trying to include a .lib file in my Visual Studio 2012 C++ project. The library is the pHash project to be specific. I have added the header file for the project to Project->Properties->Configuration Properties->VC++ Directories->Includes and the .lib file's folder to Project->Properties->Configuration Properties->VC++ Directories->Library Directories. pHash.lib has been added to the list of dependencies inProject->Properties->Configuration Properties->Linker->Input->Additional Dependencies. But even though I have done all of this I still get this error when trying to use the libraries: error LNK2019: unresolved external symbol "int __cdecl ph_dct_imagehash(char const *,unsigned __int64 &)" (?ph_dct_imagehash@@YAHPBDAA_K@Z) referenced in function _main.

My code looks as follows:

#include <iostream>
#include "pHash.h"

using namespace std;

int ph_dct_imagehash(const char *file, ulong64 &hash);

int main()
{
   ulong64 tmp = 0;
   ulong64 &hash = tmp;
   const char *file = "C:\\users\\user\\desktop\\img1.jpg";

   ph_dct_imagehash(file, hash);

   return 0;
}
user1049697
  • 2,479
  • 4
  • 29
  • 36

1 Answers1

0

You will not need the prototype

int ph_dct_imagehash(const char *file, ulong64 &hash);

after including pHash.h as the latter will declare the functions for you.

Remove that line and examine any compiler error (which, if any, will be something on the lines of not being able to find the function ph_dct_imagehash). Perhaps you'll need to prefix with a correct namespace:

somephashnamespace::ph_dct_imagehash(file, hash);
Bathsheba
  • 231,907
  • 34
  • 361
  • 483