提升asio undefined引用TLS_method,TLS_client_method等

时间:2017-06-16 14:16:12

标签: c++ ubuntu ssl boost tls1.2

美好的一天!我目前正在开发大型p2p通信服务,而且我使用的是mongoose网络服务器,我已经开始使用SSL,为了发送数据,我想我可以使用Boost中的asio。事情是我在编译时遇到错误,实际上是多个错误。

In function `boost::asio::ssl::context::context(boost::asio::ssl::context_base::method)':
/usr/local/include/boost/asio/ssl/impl/context.ipp:97: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:105: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:113: undefined reference to `TLS_server_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:142: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:150: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:158: undefined reference to `TLS_server_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:180: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:188: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:196: undefined reference to `TLS_server_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:225: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:233: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:241: undefined reference to `TLS_server_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:269: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:272: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:275: undefined reference to `TLS_server_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:281: undefined reference to `TLS_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:286: undefined reference to `TLS_client_method'
/usr/local/include/boost/asio/ssl/impl/context.ipp:291: undefined reference to `TLS_server_method'
../Anonymous/dist/Debug/GNU-Linux/libanonymous.a(http_operations.o): In function `boost::asio::ssl::context::~context()':
/usr/local/include/boost/asio/ssl/impl/context.ipp:358: undefined reference to `SSL_CTX_get_default_passwd_cb_userdata'
../Anonymousy/dist/Debug/GNU-Linux/libanonymous.a(http_operations.o): In function `boost::asio::ssl::context::set_options(long, boost::system::error_code&)':
/usr/local/include/boost/asio/ssl/impl/context.ipp:453: undefined reference to `SSL_CTX_set_options'

我的代码:

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/version.hpp>

char* process_http(int sockfd, char *host, char *page, char *poststr) {
    //This is to avoid application crash when we perform write() or read.
    signal(SIGPIPE, SIG_IGN);
    ssize_t n;
    int sendlineSize = strlen(page) + MAXLINE + 1;
    char sendline[sendlineSize];
    char *recvline = (char *) malloc(sizeof (char) * (sendlineSize));

    sprintf(sendline, "POST %s HTTP/1.0\r\n"
            "Host: %s\r\n"
            "Content-type: application/x-www-form-urlencoded\r\n"
            "Content-length: %d\r\n\r\n"
            "%s", page, host, (int) strlen(poststr), poststr);

    if (write(sockfd, sendline, sizeof (sendline)) == -1) {
        return NULL;
    }

    while ((n = read(sockfd, recvline, sendlineSize)) != 0) {
        recvline[n] = '\0';
    }

    return recvline; //this must be freed by the receiver!! ( allocated here! )
}

我怀疑代码是问题,我尝试更改标志,这是:

-lpthread -lrt -ldl -lboost_serialization -lboost_system -lboost_filesystem -lboost_thread -ltomcrypt -DLTM_DESC -lcrypto -lcrypt -fno-rtti -lboost_program_options -lboost_thread -lssl -lcrypto -lboost_system

我使用Boost进行序列化和一些文件解析,所以我怀疑升级库有问题,升级库版本是1.64,OpenSSL版本是OpenSSL 1.1.0e 2017年2月16日。 我已经验证了所有的图书馆,看起来很好,但我似乎无法找到原因。我也使用Netbeans,我没有使用命令行编译它。该项目相当大,所以我认为链接器在检测相关方法时遇到问题。

0 个答案:

没有答案