【发布时间】:2018-05-24 22:10:34
【问题描述】:
我有一个非常简单的代码:
#include <openssl/sha.h>
int main() {
SHA_CTX sha1;
SHA_Init(&sha1);
}
我已经安装了libssl-dev 和libcrypto++-dev:
但是我使用以下命令构建失败:
$ gcc -lcrypto -lssl main.c
/tmp/ccfnCAxT.o: In function `main':
main.c:(.text+0x1f): undefined reference to `SHA1_Init'
collect2: error: ld returned 1 exit status
$
$ gcc -lssl main.c
/tmp/ccfnCAxT.o: In function `main':
main.c:(.text+0x1f): undefined reference to `SHA1_Init'
collect2: error: ld returned 1 exit status
平台:Ubuntu 16.04
【问题讨论】:
-
你需要在最后指定库。试试
gcc main.c -lcrypto -lssl