I am using crypto++ in my code. I don't want to use its dependencies so i've tried to import crypto++ files in my folder and include them in my .cpp file
I have the followng errors:
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'
what am i missing? need some help. 开发者_如何学编程Appreciate! I am working in ubuntu.
You need to do two things, of which you've only done one so far.
You need to tell your compiler where to find the appropriate declarations. You've done this by adding
#include "evp.h"
in your source file. (Depending on how you installed crypto++, you might also need to tell the compiler where to find "evp.h"
, probably using -Isome_directory
.)
The step you're missing is telling the linker where to find the actual implementation (the compiled code) of the functions you're using. According to the Readme.txt
file included in the distribution, bulding crypto++ creates a library file called libcryptopp.a
.
So something like this should do the job:
gcc my_program.c -o my_program -lcryptopp
Depending on how and where you installed it, you might also need to specify -Lsome_directory
to tell the linker where to find libcryptopp.a
. (The gcc
command invokes both the compiler and the linker. The -l
option tells the linker to use libcryptopp.a
. The -L
option, if needed, tells it what directory to look in.)
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'
That's not Crypto++ - its OpenSSL.
If you need to install Crypto++ on Ubuntu, then:
root@bruno:/# apt-cache pkgnames | grep -i crypto++
libcrypto++-utils
libcrypto++8
libcrypto++8-dbg
libcrypto++-dev
libcrypto++-doc
root@bruno:/# 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.
...
精彩评论