简体   繁体   中英

cmake target link openssl error

Here is my part of 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}
)

The MESSAGE 's output

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

cmake has found OpenSSL however when I link my program aes_test with OpenSSL there is an link error.

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

In aes_test.cpp , I use function AES_set_encrypt_key which is defined in aes.h . What's wrong ? Can anyone help me? Thanks in advance.

target_link_libraries(
        aes_test
        ssl
        crypto
)

Above code works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM