2011-09-07 3115 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. 
... 
相关问题