Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `SHA1' at line

Tags:

c

linux

gcc

I try to compile a library on linux. this libary uses <openssl/sha.h> library. I have included this library in source file. After that, i use flag -lssl and flag -lcrypto to compile this project. So here is my command :

gcc -g -Wall -lssl -lcrypto -o bt_client file_a.c file_b.c

But I meet error :

undefined reference to `SHA1' at line 130

Code at line 130 is :

SHA1((unsigned char *) null_padded_name, 20, (unsigned char *)name_sha1);

Do I miss something ? Please correct me. Thanks :)

like image 894
Trần Kim Dự Avatar asked Apr 10 '14 12:04

Trần Kim Dự


2 Answers

You need to provide -lssl and -lcrypto at the end of the command line:

gcc -g -Wall -o bt_client file_a.c file_b.c -lssl -lcrypto 
like image 165
Rahul R Dhobi Avatar answered Sep 28 '22 00:09

Rahul R Dhobi


Try this:

gcc -g -Wall -o bt_client file_a.c file_b.c -lssl -lcrypto

If you are sure that symbol SHA1 exists in libssl.so or libcrypto.so.

like image 24
Lee Duhem Avatar answered Sep 28 '22 00:09

Lee Duhem