gpt4 book ai didi

c++ - cmake目标链接openssl错误

转载 作者:太空宇宙 更新时间:2023-11-04 12:47:54 24 4
gpt4 key购买 nike

这是我的 CMakeLists.txt 部分。

find_package(OpenSSL REQUIRED)

add_executable(
aes_test
src/aes_test.cpp
)

MESSAGE(${OPENSSL_FOUND})
MESSAGE(${OPENSSL_SSL_LIBRARY})

target_link_libraries(
aes_test
${OPENSSL_SSL_LIBRARY}
)

MESSAGE 的输出

TRUE
/usr/local/opt/openssl/lib/libssl.dylib

cmake 已找到 OpenSSL 但是当我将我的程序 aes_test 与 OpenSSL 链接时出现链接错误。

Undefined symbols for architecture x86_64:
"_AES_decrypt", referenced from:
_main in aes_test.cpp.o
"_AES_encrypt", referenced from:
_main in aes_test.cpp.o
"_AES_set_decrypt_key", referenced from:
_main in aes_test.cpp.o
"_AES_set_encrypt_key", referenced from:
_main in aes_test.cpp.o
ld: symbol(s) not found for architecture x86_64

aes_test.cpp 中,我使用了 aes.h 中定义的函数 AES_set_encrypt_key。怎么了 ?谁能帮我?提前致谢。

最佳答案

target_link_libraries(
aes_test
ssl
crypto
)

上面的代码对我有用。

关于c++ - cmake目标链接openssl错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50460903/

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