1

I am using ubuntu 20 and i am trying to compile my C code which uses md5 function from "<openssl/md5.h>" into a static binary.

The problem is that I get an error: undefined reference to MD5. if i compile it without static it works ok. I have tried the following methods and same error:

clang --static -I/usr/include/openssl -L/lib/x86_64-linux-gnu -lcrypto -lssl binary.c -o binary_out

 clang --static -I/usr/include/openssl -L/lib/x86_64-linux-gnu -lcrypto binary.c -o binary_out

 clang --static -I/usr/include/openssl -L/usr/lib/x86_64-linux-gnu -lcrypto binary.c -o binary_out
ams
  • 24,923
  • 4
  • 54
  • 75
James
  • 21
  • 4
  • 2
    The order of the libraries you link in matters. Try moving `binary.c` to the beginning of the your build line (or at least in front of the `-l`'s). This is for gcc, but probably worth looking at: https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc – yano Jul 20 '21 at 15:59

0 Answers0