使用整個LibTomCrypt源代碼,我已經構建了一個Visual Studio 2010庫文件,它編譯時沒有問題。但是,創建與TomCrypt庫鏈接的一個簡單的測試控制檯應用程序的時候,我收到一個鏈接錯誤以下代碼:Visual Studio 2010 LibTomCrypt構建或庫鏈接錯誤
測試代碼:
#include <stdio.h>
#include <tomcrypt.h>
int main()
{
int Cipher;
register_cipher(&aes_desc);
Cipher = find_cipher("aes");
if(Cipher != CRYPT_OK)
return 0;
printf("Cipher name: %s\n", cipher_descriptor[ Cipher ].name);
unregister_cipher(&aes_desc);
return 0;
}
鏈接錯誤 :
error LNK1120: 1 unresolved externals
error LNK2001: unresolved external symbol _aes_desc
有趣的是,調試庫構建與測試代碼完美配合。它是版本內部版本tomcrypt.lib似乎缺少一些符號。
現在,我並不是新建構和使用庫文件,但我想知道,是否有一些特定的編譯器標誌或預防措施,我可以在發佈模式下構建庫,並讓它在我的測試程序中正確鏈接?通過某種編譯器優化的方式,LibTomCrypt代碼中定義的靜態aes_desc結構是否會從庫的發佈版本中丟失?
我希望有人能爲我自己和遇到此問題的任何人提供一些見解。
您是否使用'gcc'來構建靜態庫的代碼?因爲如果是這樣,那麼它將無法工作。 – Max 2013-05-06 20:26:12