I've tried to link my C program against libssl.so
, but the linker fails to find a function in that library that does exist in the header file.
Makefile target code:
$(CC) -o $@ $^ $(CFLAGS) -lssl -lmagic
Output:
...
/usr/bin/ld: obj/signature.o: undefined reference to symbol 'SHA256_Init@@OPENSSL_1_1_0'
//usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
...
The function is SHA256_Init()
and it is present in openssl/sha.h
that it included in the source file.
I'm on Debian 9. I have the following packages installed: libssl1.0.0
, libssl1.0.2
, libssl1.1
, libssl-dev
(1.1.0).
$ la /usr/lib/x86_64-linux-gnu/libssl*
-rw-r--r-- root root 357024 /usr/lib/x86_64-linux-gnu/libssl3.so
-rw-r--r-- root root 738444 /usr/lib/x86_64-linux-gnu/libssl.a
lrwxrwxrwx root root 13 /usr/lib/x86_64-linux-gnu/libssl.so -> libssl.so.1.1
-rw-r--r-- root root 395176 /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
-rw-r--r-- root root 431232 /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2
-rw-r--r-- root root 442920 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
What am I doing wrong and how to solve the problem?