Reputation: 1101
I have a very simple code:
#include <openssl/sha.h>
int main() {
SHA_CTX sha1;
SHA_Init(&sha1);
}
I have installed both libssl-dev
and libcrypto++-dev
:
However I have a build failure using the following command:
$ gcc -lcrypto -lssl main.c
/tmp/ccfnCAxT.o: In function `main':
main.c:(.text+0x1f): undefined reference to `SHA1_Init'
collect2: error: ld returned 1 exit status
$
$ gcc -lssl main.c
/tmp/ccfnCAxT.o: In function `main':
main.c:(.text+0x1f): undefined reference to `SHA1_Init'
collect2: error: ld returned 1 exit status
Platform: Ubuntu 16.04
Upvotes: 0
Views: 381
Reputation: 2166
-lssl
is not needed, -lcrypto
is enough, and it must be at the end:
gcc -o main main.c -lcrypto
(or whatever you want your program to be called goes after -o
)
Upvotes: 1