2011-09-07 3121 views
2

我在我的代碼中使用crypto ++。我不想使用它的依賴,所以我已經盡力匯入我的文件夾中的加密+ +文件,包括他們在我的.cpp文件鏈接錯誤:未定義引用EVP_CIPHER_CTX_和EVP_CIPHER_CTX_init

我有followng錯誤:

TEST.cpp:(.text+0x89a0): undefined reference to `EVP_CIPHER_CTX_init' 
TEST.cpp:(.text+0x8cb0): undefined reference to `EVP_aes_128_cbc' 
TEST.cpp:(.text+0x8cdd): undefined reference to `EVP_CipherInit_ex' 
TEST.cpp:(.text+0x8d49): undefined reference to `EVP_CipherUpdate' 
TEST.cpp:(.text+0x8dd6): undefined reference to `EVP_CipherFinal_ex' 
TEST.cpp:(.text+0x922d): undefined reference to `EVP_CIPHER_CTX_cleanup' 

我失去了什麼?需要一些幫助。欣賞! 我在ubuntu工作。

+1

哪些文件具有您導入?只有標題或源代碼?只導入標題是不夠的,因爲你的應用程序必須鏈接到加密++對象文件(庫) – istepura

+0

我只導入了「evp.h」。我應該輸入什麼?需要一些幫助。謝謝 – sunset

回答

3

你需要做兩件事,其中你迄今只做過一件事。

你需要告訴你的編譯器在哪裏找到適當的聲明。您已通過在源文件中添加

#include "evp.h" 

。 (取決於你如何安裝加密++,你可能還需要告訴編譯器在哪裏可以找到"evp.h",可能使用-Isome_directory

你缺少告訴鏈接器在哪裏可以找到實際執行的步驟(編譯後的代碼)你正在使用的功能。根據發行版中包含的Readme.txt文件,bulding crypto ++會創建一個名爲libcryptopp.a的庫文件。

所以這樣的事情應該做的工作:

gcc my_program.c -o my_program -lcryptopp 

根據您在哪裏如何安裝它,您可能還需要指定-Lsome_directory告訴鏈接在哪裏可以找到libcryptopp.a。 (該gcc命令調用編譯器和鏈接器的-l選項告訴編譯器使用libcryptopp.a鏈接的-L選項,如果需要的話,告訴它看在哪個目錄。)

0
TEST.cpp:(.text+0x89a0): undefined reference to `EVP_CIPHER_CTX_init' 
TEST.cpp:(.text+0x8cb0): undefined reference to `EVP_aes_128_cbc' 
TEST.cpp:(.text+0x8cdd): undefined reference to `EVP_CipherInit_ex' 
TEST.cpp:(.text+0x8d49): undefined reference to `EVP_CipherUpdate' 
TEST.cpp:(.text+0x8dd6): undefined reference to `EVP_CipherFinal_ex' 
TEST.cpp:(.text+0x922d): undefined reference to `EVP_CIPHER_CTX_cleanup' 

這不是加密+ - 其OpenSSL的。


如果您需要安裝加密+ Ubuntu上,然後:

[email protected]:/# apt-cache pkgnames | grep -i crypto++ 
libcrypto++-utils 
libcrypto++8 
libcrypto++8-dbg 
libcrypto++-dev 
libcrypto++-doc 

[email protected]:/# apt-get install libcrypto++8 libcrypto++8-dbg libcrypto++-dev 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
The following NEW packages will be installed: 
    libcrypto++-dev libcrypto++8 libcrypto++8-dbg 
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 
Need to get 10.7MB of archives. 
... 
相關問題