【发布时间】:2021-08-23 09:56:21
【问题描述】:
我正在尝试编译这个超级简单的代码:
#include <openssl/bn.h>
int main(void)
{
BIGNUM *k = BN_new();
}
我使用以下命令:
gcc-11 test.c -I/opt/homebrew/opt/openssl@1.1/include -L/opt/homebrew/opt/openssl@1.1/lib
我明白了
gcc-11 test.c -I/opt/homebrew/opt/openssl@1.1/include -L/opt/homebrew/opt/openssl@1.1/lib
Undefined symbols for architecture arm64:
"_BN_new", referenced from:
_main in ccRnO859.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
这里有更多信息:
% file $(which gcc-11)
/opt/homebrew/bin/gcc-11: Mach-O 64-bit executable arm64
% gcc-11 --version
gcc-11 (Homebrew GCC 11.1.0) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% file /opt/homebrew/opt/openssl@1.1/lib/libcrypto.dylib
/opt/homebrew/opt/openssl@1.1/lib/libcrypto.dylib: Mach-O 64-bit dynamically linked shared library arm64
% nm -gU /opt/homebrew/opt/openssl@1.1/lib/libcrypto.dylib|grep _BN_new
00000000000311bc T _BN_new
编辑:我用 x86_64 版本的 GCC 和 OpenSSL 进行了完全相同的尝试,它给出了相同的结果
【问题讨论】: