Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

C: error when linking with OpenSSL library dynamically

$
0
0

I have a C program, which is using AES routines from the OpenSSL library. I have the necessary library installed (libssl-dev)

I can compile my program statically:

gcc -s -o aes aes.c /usr/lib/x86_64-linux-gnu/libcrypto.a

but when i try to compile it dynamically, I get following error:

$ gcc -s -o aes aes.c -lcrypto
/tmp/ccofFr4N.o: In function `encrypt':
aes.c:(.text+0x9f): undefined reference to `aesni_set_encrypt_key'
aes.c:(.text+0xd9): undefined reference to `aesni_cbc_encrypt'
aes.c:(.text+0x1a0): undefined reference to `aesni_cbc_encrypt'
/tmp/ccofFr4N.o: In function `decrypt':
aes.c:(.text+0x2d4): undefined reference to `aesni_set_decrypt_key'
aes.c:(.text+0x31e): undefined reference to `aesni_cbc_encrypt'
collect2: error: ld returned 1 exit status

Why can't I compile my program with OpenSSL linked dynamically ?

UPDATE

So, here are the libraries from libssl-dev:

$ ls /usr/lib/x86_64-linux-gnu/libcrypto.*
/usr/lib/x86_64-linux-gnu/libcrypto.a
/usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

I noticed the following. When I grep them for the name of the AES function, only libcrypto.a matches.

$ grep aesni_set_encrypt_key /usr/lib/x86_64-linux-gnu/libcrypto.*
Binary file /usr/lib/x86_64-linux-gnu/libcrypto.a matches

Shouldn't /usr/lib/x86_64-linux-gnu/libcrypto.so contain these functions as well ?


Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>