[英]Unresolved externals in Visual C++
我正在嘗試在MS Visual Studio C ++ 2012中編譯解決方案。
我的代碼使用marshallsoft AES
庫。
我為庫添加了這些,並包含路徑:
C:\\aes4c\\APPS
到Configuration properties->VC++ Directories->Include Directories
C:\\aes4c\\DLLS
到Configuration properties->VC++ Directories->Library Directories
當我編譯單個.cpp
文件時,它可以毫無問題地進行編譯,但是當我構建解決方案時,我得到:
------ Build started: Project: cryptest2, Configuration: Debug Win32 ------
cryptest2.obj : error LNK2019: unresolved external symbol __imp__aesAttach@8 referenced in function "int __cdecl EncryptFileW(char *,char *)" (?EncryptFileW@@YAHPAD0@Z)
cryptest2.obj : error LNK2019: unresolved external symbol __imp__aesEncryptFile@12 referenced in function "int __cdecl EncryptFileW(char *,char *)" (?EncryptFileW@@YAHPAD0@Z)
cryptest2.obj : error LNK2019: unresolved external symbol __imp__aesInitAES@20 referenced in function "int __cdecl EncryptFileW(char *,char *)" (?EncryptFileW@@YAHPAD0@Z)
C:\Users\ariyan\documents\visual studio 2012\Projects\cryptest2\Debug\cryptest2.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
問題是什么?
我該如何解決?
我的代碼是:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include "aes.h"
int EncryptFile(char *KeyBuffer, char *FileName);
int _tmain(int argc, _TCHAR* argv[])
{
EncryptFile("1234567890abcdef","c:\test.txt");
return 0;
}
int EncryptFile(char *KeyBuffer, char *FileName)
{int Code;
// attach DLL
Code = aesAttach(0, 0);
if(Code<0)
{printf("ERROR %d: Cannot attach\n", Code);
return FALSE;
}
printf("Will encrypt file in CBC mode\n");
Code = aesInitAES((char *)KeyBuffer, NULL, AES_ECB_MODE, AES_ENCRYPT, NULL);
if(Code<0)
{printf("aesInitAES fails\n");
return FALSE;
}
printf("Encrypt file...\n");
Code = aesEncryptFile(NULL, KeyBuffer, FileName);
if(Code<0)
{printf("aesEncryptFile fails\n");
return FALSE;
}
printf("%d bytes encrypted\n", Code);
return Code;
}
這是不夠的,添加到庫路徑-這只是告訴鏈接到哪里尋找庫,如果當它決定與它聯系起來。 但是您必須首先告訴鏈接器尋找它。 為此,請在中提及LIB文件名
項目>屬性>鏈接器>輸入>其他依賴項
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.