【问题标题】:Unresolved externals in Visual C++Visual C++ 中未解析的外部
【发布时间】:2014-01-08 15:48:13
【问题描述】:

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

【问题讨论】:

    标签: visual-c++ visual-studio-2012 linker


    【解决方案1】:

    仅添加到库路径是不够的 - 这只是告诉链接器在哪里 在决定与它链接时查找库。但是您必须首先告诉链接器查找它。为此,请在

    中提及 LIB 文件名

    项目 > 属性 > 链接器 > 输入 > 附加依赖项

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-08
      • 2014-07-28
      • 2013-02-28
      • 2012-11-19
      相关资源
      最近更新 更多