Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to md5 [duplicate]

#include <openssl/md5.h>
void mMD5(unsigned char * packet, int size) {

    unsigned char* res;

    MD5((unsigned char*)&packet, size, (unsigned char*)&res);

    for(int i=0; i<MD5_DIGEST_LENGTH; i++) {
        printf("%02x", res[i]);
    }
}

I get the error: undefined reference to MD5

Can anyone help me?

like image 554
Bewn Avatar asked Mar 20 '12 19:03

Bewn


1 Answers

You need to link to the matching library. You should have a file called md5.lib or md5.a or something like that (depending on your OS), and add it to your linker command line (again, depending on your environment).

like image 96
Asaf Avatar answered Nov 15 '22 00:11

Asaf