繁体   English   中英

Visual C ++中无法解析的外部

[英]Unresolved externals in Visual C++

我正在尝试在MS Visual Studio C ++ 2012中编译解决方案。
我的代码使用marshallsoft AES库。
我为库添加了这些,并包含路径:

  • C:\\aes4c\\APPSConfiguration properties->VC++ Directories->Include Directories
  • C:\\aes4c\\DLLSConfiguration 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM