Visual Studio 2012 - 尝试包含.lib时出现“错误LNK2019未解析的外部符号”

时间:2013-09-16 11:16:29

标签: c++ visual-studio-2012 dll phash

我正在尝试在Visual Studio 2012 C ++项目中包含.lib文件。该库是具体的pHash项目。我已将项目的头文件添加到Project->Properties->Configuration Properties->VC++ Directories->Includes,将.lib文件的文件夹添加到Project->Properties->Configuration Properties->VC++ Directories->Library DirectoriespHash.lib已添加到Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies中的依赖项列表中。但即使我已经完成了所有这些操作,我仍然在尝试使用库时遇到此错误:error LNK2019: unresolved external symbol "int __cdecl ph_dct_imagehash(char const *,unsigned __int64 &)" (?ph_dct_imagehash@@YAHPBDAA_K@Z) referenced in function _main

我的代码如下:

#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;
}

1 个答案:

答案 0 :(得分:0)

您不需要原型

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

包括pHash.h后,后者会为你声明这些功能。

删除该行并检查任何编译器错误(如果有的话,将会出现无法找到函数ph_dct_imagehash的行)。也许您需要使用正确的命名空间作为前缀:

somephashnamespace::ph_dct_imagehash(file, hash);