簡體   English   中英

Visual Studio 2012-嘗試包含.lib時出現“錯誤LNK2019無法解析的外部符號”

[英]Visual Studio 2012 - “Error LNK2019 unresolved external symbol” when attempting to include .lib

我試圖在我的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;
}

您將不需要原型

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

在包含pHash.h因為后者將為您聲明函數。

刪除該行並檢查所有編譯器錯誤(如果有的話,將是無法找到函數ph_dct_imagehash )。 也許您需要為前綴添加正確的名稱空間:

somephashnamespace::ph_dct_imagehash(file, hash);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM