0
votes

Okay, I need to use md5() function from OpenSSL library, but when I compile gcc gives me an error - "undefined reference to md5". I tried few things, which I found in different StackOverFlow questions, but still no effect.

First of all I installed packages (Ubuntu 13.04):

sudo apt-get install openssl

sudo apt-get install libssl-dev

In my source I included openssl/md5 and I tried to compile everything this way:

gcc main.c -lssl -lcrypto

or

gcc main.c -L/home/usr/lib -lssl -lcrypto

What am I missing? Please help.

1
You need to show us your code, and the actual commands you are running, and the actual output of those commands, including any error messages. - larsks
After installing libssl-dev and compiling with gcc main.c -lssl -lcrypto, things should have worked. That's because apt-get puts the libraries in /usr/lib and the compiler/linker could find them. So you have another problem that's not readily apparent. Clean your project and start again or show us the make command. - jww
Also, you sometimes need to link against -ldl and -lpthread, too. Add them after -lssl -lcrypto. - jww
The line i include is #include <openssl/md5.h> - francis

1 Answers

1
votes

It looks like that your OpenSSL is compiled with no-md5 option. So, download OpenSSL and build it with md5 if required.