I'm trying to compile a solution in MS Visual Studio C++ 2012.
My code uses marshallsoft AES
library.
I added these for library and include paths:
C:\\aes4c\\APPS
to Configuration properties->VC++ Directories->Include Directories
C:\\aes4c\\DLLS
to Configuration properties->VC++ Directories->Library Directories
When I compile the individual .cpp
file it compiles without problem but when I build the solution I get:
------ 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 ==========
What is the problem?
How Can I fix it?
My code is:
#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;
}
It's not enough to add to library path - that just tells the linker where to look for a library if and when it decides to link with it. But you have to tell the linker to look for it in the first place. For that, mention the LIB file name in
Project > Properties > Linker > Input > Additional Dependencies
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.