如何解决Mac M1 openssl CLion 编译问题
我有以下任务:编写一个创建 dh 参数的 C/C++ 程序。
我使用 CLion。最初安装的是 OpenSSL,我可以在终端中使用所有 OpenSSL 命令。
MacBook-Air-Nikita ~ % openssl version
LibreSSL 2.8.3
但是,在 CLion 中,我无法添加任何库,因为它看不到它。我使用 Brew 成功安装了新的 OpenSSL;它有这个路径:
/opt/homebrew/Cellar/openssl@1.1/1.1.1i/
但是 CLion 没有看到任何库。所以我将这些行添加到项目 CMakeList.txt 中:
include_directories(/usr/local/Cellar/openssl@1.1/1.1.1i/include/)
set(OPENSSL_ROOT_DIR /usr/local/Cellar/openssl@1.1/1.1.1i/ )
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
之后,我可以包含我想要的所有库,但它不起作用。当我尝试使用库中的任何函数运行程序时,构建器失败。
#include <openssl/rand.h>
int main(){
RAND_bytes(10,10);
return 0;
}
错误:
Undefined symbols for architecture arm64:
"_RAND_bytes",referenced from:
_main in main.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [PV181_HW03] Error 1
make[2]: *** [CMakeFiles/PV181_HW03.dir/all] Error 2
make[1]: *** [CMakeFiles/PV181_HW03.dir/rule] Error 2
make: *** [PV181_HW03] Error 2
有人能告诉我如何解决这个问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。