1

I have the following code:

#include <stdio.h>
#include <stdlib.h>
#include <openssl/evp.h>
int main (int argc, char *argv[]) {
    EVP_CIPHER *cipher;
    EVP_idea_ecb();
}

I know, this is not much, but it should compile without complaints, but I get

gcc Testfile.c -lssl -lcrypto
Testfile.c:(.text+0xec): undefined reference to `EVP_idea_ecb'

gcc Testfile.c -lss
/usr/bin/ld: /tmp/ccgbkhFA.o: undefined reference to symbol 'EVP_CIPHER_iv_length@@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: error adding symbols: DSO missing from command linel

libssl-dev are installed. Any ideas what is going wrong here?

My distro: Debian Jessie on x64.

jww
  • 97,681
  • 90
  • 411
  • 885
user3417078
  • 265
  • 4
  • 15
  • You also need to call `OpenSSL_add_ssl_algorithms` and `SSL_load_error_strings`. See [Library Initialization](http://wiki.openssl.org/index.php/Library_Initialization) on the OpenSSL wiki. `OpenSSL_add_ssl_algorithms` and `SSL_library_init` are synonymous (you can use either one, but one should be used). – jww Jan 13 '15 at 18:16

1 Answers1

2

What is going on line by line:

gcc Testfile.c -lssl -lcrypto
Testfile.c:(.text+0xec): undefined reference to `EVP_idea_ecb'

OpenSSL library of Debian Jessie x64 doesn't contain EVP_idea_ecb.

gcc Testfile.c -lss
/usr/bin/ld: /tmp/ccgbkhFA.o: undefined reference to symbol 'EVP_CIPHER_iv_length@@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: error adding symbols: DSO missing from command linel

libss.so.2.0 from libss2 command line interface library package doesn't help either.

Vladimir Kunschikov
  • 1,735
  • 1
  • 16
  • 16
  • 2
    *"OpenSSL library of Debian Jessie x64 doesn't contain EVP_idea_ecb"* - you should use something like `nm -D /usr/lib/i386-linux-gnu/libcrypto.so | grep -i EVP_idea_ecb` to confirm (or deny) the symbol. Its not present in Wheezy either. – jww Jan 13 '15 at 18:34
  • Thanks for your comment. Yes, EVP_idea is not avaible in libcrypto.so so that's why gcc is returning this error. But in evp.h there is a symbol, that's I thought, that this function should be availble and im calling gcc with the wrong parameters. I installed Fedora in Virtualbox. Now I can do what I want. – user3417078 Jan 13 '15 at 20:54