#RB2 SHA1 computation in C

I’m stuck on Stage #RB2. The program does not seem to compile with Codecrafters because the SHA1 function in openssl/sha.h cannot be found.


When compiling locally, it compiles only with the slightly modified bash script where I put the -lcurl -lcrypto links at the end thus:
gcc src/main.c -o $tmpFile -lcurl -lcrypto
But changing the placement of the links in the your_bittorrent.sh script:
gcc app/*.c -o $tmpFile -lcurl -lcrypto
does not have a similar effect. The program still fails to compile for the same reasons, with the same output (see attached screenshot).

Any help would be very much appreciated!

Hey @ptrhcpang, thanks for sharing the details!

To resolve the issue, you can add the following two lines to CMakeLists.txt:

find_package(OpenSSL REQUIRED)
target_link_libraries(bittorrent OpenSSL::Crypto)

This will ensure the SHA1 function from openssl/sha.h is properly linked.

Ah, fantastic! Thank you so much. I wasn’t sure what the MakeList file did, but shall read up on this and links when I have some time. Thank you again.

1 Like