gpt4 book ai didi

linux - 将 OpenSSL 库链接到程序

转载 作者:IT王子 更新时间:2023-10-29 00:22:30 26 4
gpt4 key购买 nike

我已经从源代码构建了 OpenSSL(故意使用旧版本;使用 ./config && make && make test 构建)并且更愿意使用我构建的内容而无需执行 make install 链接到我的程序。

失败的命令是:

gcc -Wall -Wextra -Werror -static -Lopenssl/openssl-0.9.8k/ -lssl -lcrypto 
-Iopenssl/openssl-0.9.8k/include -o myApp source1.o source2.o common.o`

我收到了一系列类似于以下的错误:

common.c:(.text+0x1ea): undefined reference to `SSL_write'

这让我觉得我的 OpenSSL 有点奇怪。如果我从我的命令中省略 -Lopenssl/openssl-0.9.8k/,错误将变为无法:

/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto

我是否错误地编译了 OpenSSL?或者我应该如何最好地解决这个问题?

最佳答案

愚蠢的“Linux 主义”再次来袭!显然,我需要更改我的命令,使 -L-l 东西像末尾一样(尽管 man gcc 似乎表明):

gcc -Wall -Wextra -Werror -static -o myApp source1.o source2.o common.o -Lopenssl/openssl-0.9.8k/-lssl -lcrypto -Iopenssl/openssl-0.9.8k/include

关于linux - 将 OpenSSL 库链接到程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4352573/

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