使用OpenSSL功能的项目在Ubuntu上编译失败但在Fedora上编译成功

问题描述 投票:0回答:1

我正在尝试从以下 GitHub 存储库编译 nwipe 项目:https://github.com/Knogle/nwipe/tree/master。编译过程在 Fedora 系统上成功完成,但在具有相同 OpenSSL 版本(大于 3.0.2)的 Ubuntu 计算机上失败,该版本应该支持必要的功能。两个系统都正确安装了 libdev-ssl 软件包。

这是 Fedora 上的编译输出片段,编译时没有错误:

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -MT aes/aes_ctr_prng.o -MD -MP -MF $depbase.Tpo -c -o aes/aes_ctr_prng.o aes/aes_ctr_prng.c &&\
mv -f $depbase.Tpo $depbase.Po
...
gcc -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lcrypto -o nwipe nwipe.o ... -lparted -lpthread -lpanel -lncurses -ltinfo -lconfig

但是,在 Ubuntu 上,我遇到与 OpenSSL 函数

AES_set_encrypt_key
AES_encrypt
相关的链接器错误,这些函数自 OpenSSL 3.0 起被标记为已弃用,但仍包含在项目中:

/usr/bin/ld: aes/aes_ctr_prng.o: in function `aes_ctr_prng_init':
/tmp/nwipe/src/aes/aes_ctr_prng.c:22: undefined reference to `AES_set_encrypt_key'
/usr/bin/ld: aes/aes_ctr_prng.o: in function `aes_ctr_prng_genrand_uint32':
/tmp/nwipe/src/aes/aes_ctr_prng.c:41: undefined reference to `AES_encrypt'
/usr/bin/ld: /tmp/nwipe/src/aes/aes_ctr_prng.c:41: undefined reference to `CRYPTO_ctr128_encrypt'
collect2: error: ld returned 1 exit status

鉴于在 Fedora 上编译成功,但在 Ubuntu 上编译失败,尽管具有相同的 OpenSSL 版本并且安装了看似正确的依赖项,可能会导致此问题的原因是什么?如何解决 Ubuntu 上的这些链接器错误?

c ubuntu encryption compilation openssl
1个回答
0
投票

此链接命令...

gcc -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lcrypto -o nwipe nwipe.o ... -lparted -lpthread -lpanel -lncurses -ltinfo -lconfig

... 在命令行上错误地放置了

-lcrypto
。它应该遵循调用其任何函数的所有目标文件(以及任何库)。目前尚不清楚为什么该构建在 Fedora 上仍然有效,但在 Ubuntu 上失败也就不足为奇了。

我认为项目的构建系统负责该放置,而不是您个人。在这种情况下,您正在寻找一个缺陷,您应该将其报告给项目的开发团队。如果您觉得有能力这样做,那么您同时可以尝试自己修复它,但您没有提供足够的信息让我们为您修复它..

© www.soinside.com 2019 - 2024. All rights reserved.