(#RB2) lcrypto and OpenSSL library problem (BitTorrent-Client in C)

Hi @rohitpaulk

I know I emailed you concerning the issue of using OpenSSL library for stage 6 of the bitTorrent client. I got the response that this has been updated, however, I still seem to be getting the error. Could it be something else? Can anyone perhaps help me here?

It says undefined reference to SHA1 (OpenSSL). I am compiling with -lcrypto and included openssl.h in my code. Here is a screenshot of compiling locally, but it seems to fail when I test.

I was able to come to this conclusion because I commented out the use of SHA1() function in my code, and it complied successfully when I tested. But of course, the results were wrong, since I didnt actually hash.

char *bencoded_info = bencode(info);
    size_t length = strlen(bencoded_info);
    
    // using sha1 hash
    unsigned char *hash = malloc(SHA_DIGEST_LENGTH);
    // SHA1((unsigned char*)bencoded_info, length, hash);

I can provide more snippets if needed, please let me know

@sinmi-hub hmm, that’s weird - can you confirm whether you’ve added -lcrypto to your_bittorrent.sh?

Ahh that was it! I added to my makefile, but not the bash script. I forgot that it uses your_bittorrent.sh. Thank you!

Ah, glad to hear it’s fixed!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Note: I’ve updated the title of this post to include the stage ID (#RB2). You can learn about the stages rename here: Upcoming change: Stages overhaul.