我正在尝试在Visual Studio 2012 C ++项目中包含.lib
文件。该库是具体的pHash项目。我已将项目的头文件添加到Project->Properties->Configuration Properties->VC++ Directories->Includes
,将.lib
文件的文件夹添加到Project->Properties->Configuration Properties->VC++ Directories->Library Directories
。 pHash.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;
}
答案 0 :(得分:0)
您不需要原型
int ph_dct_imagehash(const char *file, ulong64 &hash);
包括pHash.h
后,后者会为你声明这些功能。
删除该行并检查任何编译器错误(如果有的话,将会出现无法找到函数ph_dct_imagehash
的行)。也许您需要使用正确的命名空间作为前缀:
somephashnamespace::ph_dct_imagehash(file, hash);