gpt4 book ai didi

使用 libssl 编译不起作用

转载 作者:行者123 更新时间:2023-11-30 14:48:17 27 4
gpt4 key购买 nike

我有一个非常简单的代码:

#include <openssl/sha.h>

int main() {
SHA_CTX sha1;
SHA_Init(&sha1);
}

我已经安装了 libssl-devlibcrypto++-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

最佳答案

-lssl不需要,-lcrypto就够了,而且必须在最后:

gcc -o main main.c -lcrypto

(或者您希望在 -o 之后调用程序的任何内容)

关于使用 libssl 编译不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50518881/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com