boost::asio::ssl linking errors in Xcode 4

2019-07-29 09:24发布

问题:

I have a simple project in Xcode—it doesn't actually do anything yet, just includes boost::asio::ssl:

// main.cpp

#include <iostream>
#include <string>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>

using namespace std ;

int main (int argc, const char * argv [] ) {
    return 0 ;
}

I have it linked with libssl.dylib and libboost_system.dylib, and get this when building:

Undefined symbols for architecture x86_64:
  "_CONF_modules_unload", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_CRYPTO_cleanup_all_ex_data", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_CRYPTO_num_locks", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::do_init() in main.o
  "_CRYPTO_set_id_callback", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::do_init() in main.o
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_CRYPTO_set_locking_callback", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::do_init() in main.o
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_ENGINE_cleanup", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_ERR_free_strings", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_ERR_reason_error_string", referenced from:
      boost::asio::error::detail::ssl_category::message(int) const in main.o
  "_ERR_remove_state", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_EVP_cleanup", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.o
  "_OPENSSL_add_all_algorithms_noconf", referenced from:
      boost::asio::ssl::detail::openssl_init_base::do_init::do_init() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there some other library I'm missing or something else I've overlooked?

回答1:

I think you need to link against libcrypto as well -lcrypto