我使用gcc版本4.2.1
和openssl版本0.9.8r 8 Feb 2011
,我尝试了以下代码段
#include<string.h>
#include<stdio.h>
#include<openssl/md5.h>
int main() {
char test[] = "test";
unsigned char d[16];
MD5_CTX c;
MD5_Init(&c);
MD5_Update(&c, (char *)test, strlen(test));
MD5_final(d, &c);
}
编译为gcc -o t <filename.c>
会出现以下错误: -
Undefined symbols:
"_MD5_Update", referenced from:
_main in ccxSwMKm.o
"_MD5_Init", referenced from:
_main in ccxSwMKm.o
"_MD5_final", referenced from:
_main in ccxSwMKm.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
有什么明显的东西我做错了吗?
答案 0 :(得分:3)
尝试将-lcrypto
添加到命令行。