Visual Studio 2012 - 尝试包含 .lib 时"Error LNK2019 unresolved external symbol"

Visual Studio 2012 - "Error LNK2019 unresolved external symbol" when attempting to include .lib

本文关键字:Error LNK2019 unresolved symbol external lib 2012 Studio 包含 Visual      更新时间:2023-10-16

我正在尝试在我的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;
}

你不需要原型

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

包含pHash.h后,后者将为您声明函数。

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

somephashnamespace::ph_dct_imagehash(file, hash);