【问题标题】:ld: symbol(s) not found with OpenSSL (libssl)ld:在 OpenSSL (libssl) 中找不到符号
【发布时间】:2011-02-27 03:40:18
【问题描述】:

我正在尝试在我的 Mac 上构建 TorTunnel。我已经成功安装了 Boost 库及其开发文件。 TorTunnel 还需要 OpenSSL 及其开发文件。

我已将它们安装在 /usr/lib/libssl.dylib 和 /usr/include/openssl/ 中。

当我运行 make 命令时,这是我得到的错误:

g++ -ggdb -g -O2 -lssl -lboost_system-xgcc42-mt-1_38 -o torproxy TorProxy.o HybridEncryption.o Connection.o Cell.o Directory.o ServerListing.o Util.o Circuit.o CellEncrypter.o RelayCellDispatcher.o CellConsumer.o ProxyShuffler.o CreateCell.o CreatedCell.o TorTunnel.o SocksConnection.o Network.o 未定义的符号: “_BN_hex2bn”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() “_BN_free”,引用自: Circuit::~Circuit() in Circuit.o Circuit::~Circuit() in Circuit.o CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o “_DH_generate_key”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() “_PEM_read_bio_RSAPublicKey”,引用自: ServerListing.o 中的 ServerListing::getOnionKey() “_BIO_s_mem”,引用自: Connection.o 中的 Connection::initializeSSL() Connection.o 中的 Connection::initializeSSL() “_DH_free”,引用自: Circuit::~Circuit() in Circuit.o “_BIO_ctrl_pending”,引用自: Connection.o 中的 Connection::writeFromBuffer(boost::function) “_RSA_size”,引用自: HybridEncryption::encryptInSingleChunk(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o HybridEncryption::encryptInHybridChunk(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o HybridEncryption::encrypt(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o “_RSA_public_encrypt”,引用自: HybridEncryption::encryptInSingleChunk(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o HybridEncryption::encryptInHybridChunk(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o “_BN_num_bits”,引用自: CreateCell::CreateCell(unsigned short, dh_st*, rsa_st*) in CreateCell.o CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o CreatedCell.o 中的 CreatedCell::isValid() “_SHA1”,引用自: CellEncrypter::expandKeyMaterial(unsigned char*, int, unsigned char*, int) in CellEncrypter.o “_BN_bn2bin”,引用自: CreateCell::CreateCell(unsigned short, dh_st*, rsa_st*) in CreateCell.o “_BN_bin2bn”,引用自: CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o “_DH_compute_key”,引用自: CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o “_BIO_new”,引用自: Connection.o 中的 Connection::initializeSSL() Connection.o 中的 Connection::initializeSSL() “_BIO_new_mem_buf”,引用自: ServerListing.o 中的 ServerListing::getOnionKey() “_AES_ctr128_encrypt”,引用自: HybridEncryption::AES_encrypt(unsigned char*, int, unsigned char*, unsigned char*, int) in HybridEncryption.o CellEncrypter::aesOperate(Cell&, aes_key_st*, unsigned char*, unsigned char*, unsigned int*) in CellEncrypter.o “_BIO_read”,引用自: Connection.o 中的 Connection::writeFromBuffer(boost::function) “_SHA1_Update”,引用自: CellEncrypter::calculateDigest(SHAstate_st*, RelayCell&, unsigned char*) in CellEncrypter.o CellEncrypter::initKeyMaterial(unsigned char*) in CellEncrypter.o CellEncrypter::initKeyMaterial(unsigned char*) in CellEncrypter.o “_SHA1_Final”,引用自: CellEncrypter::calculateDigest(SHAstate_st*, RelayCell&, unsigned char*) in CellEncrypter.o “_DH_size”,引用自: CreatedCell::getKeyMaterial(unsigned char**, unsigned char**) in CreatedCell.o “_DH_new”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() “_BIO_write”,引用自: Connection::readIntoBufferComplete(boost::function, boost::system::error_code const&, unsigned long) 在 Connection.o “_RSA_free”,引用自: Circuit::~Circuit() in Circuit.o “_BN_dup”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() Circuit.o 中的 Circuit::initializeDhParameters() “_BN_new”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() Circuit.o 中的 Circuit::initializeDhParameters() “_SHA1_Init”,引用自: CellEncrypter::CellEncrypter() in CellEncrypter.o CellEncrypter::CellEncrypter() in CellEncrypter.o “_RAND_bytes”,引用自: HybridEncryption::encryptInHybridChunk(unsigned char*, int, unsigned char**, int*, rsa_st*)in HybridEncryption.o Util.o 中的 Util::getRandomId() “_AES_set_encrypt_key”,引用自: HybridEncryption::AES_encrypt(unsigned char*, int, unsigned char*, unsigned char*, int) in HybridEncryption.o CellEncrypter::initKeyMaterial(unsigned char*) in CellEncrypter.o CellEncrypter::initKeyMaterial(unsigned char*) in CellEncrypter.o “_BN_set_word”,引用自: Circuit.o 中的 Circuit::initializeDhParameters() “_RSA_new”,引用自: ServerListing.o 中的 ServerListing::getOnionKey() ld:未找到符号 collect2: ld 返回 1 个退出状态 make: *** [torproxy] 错误 1

知道如何解决吗?

【问题讨论】:

    标签: c++ openssl


    【解决方案1】:

    你还需要 libcrypto。

    将您的链接行更改为:

    g++ -ggdb -g -O2 -lssl -lcrypt ... as before ...
    

    【讨论】:

      【解决方案2】:

      至少有一个缺失的符号不是 libssl 的一部分,而是 libcrypto 的一部分:

      diciu:~ diciu$ nm /usr/lib/libcrypto.dylib | grep PEM_read_bio_RSAPublicKey
      00031d20 T _PEM_read_bio_RSAPublicKey
      

      将“-lcrypto”添加到您的编译行。

      【讨论】:

        【解决方案3】:

        如果 /opt/local/lib 中已经安装了 libcrypto,请将 -lcrypt 标志更改为 -lcrypto 标志。

         g++ -ggdb -g -O2 -L/opt/local/lib -L/usr/lib -lssl -lcrypto -lboost_system-mt
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-04-11
          • 1970-01-01
          • 1970-01-01
          • 2018-10-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多