How to use cpp-netlib with Visual Studio 2010?

感情迁移 提交于 2019-12-11 06:12:54

问题


I'm trying to use cpp-netlib with Visual Studio 2010. I've built cpp-netlib and add .lib files to my project, but I can't compile them.

--Environment

  • Windows 7 x64
  • cpp-netlib 0.11.0
  • boost 1.55.0
  • Win32 OpenSSL v1.0.1f

My code is here.

#include <boost/network/protocol/http/client.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
    using namespace boost::network;

    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " [url]" << std::endl;
        return 1;
    }

    http::client client;
    http::client::request request(argv[1]);
    request << header("Connection", "close");
    http::client::response response = client.get(request);
    std::cout << body(response) << std::endl;

    return 0;
}

I added the cpp-netlib library path and the cpp-netlib include path to the project. Boost and openssl paths were also added. I added the libs to the project.

  • libboost_system-vc100-mt-gd-1_55.lib
  • libboost_date_time-vc100-mt-gd-1_55.lib
  • libboost_regex-vc100-mt-gd-1_55.lib
  • cppnetlib-client-connections.lib
  • cppnetlib-uri.lib

I think the errors come from something related OpenSSL.

Error   55  error LNK2019: unresolved external symbol - function _BIO_ctrl ...

Actually, I have Japanese one so it's like below.

エラー 55  error LNK2019: 未解決の外部シンボル _BIO_ctrl が関数 "public: class boost::system::error_code const & __thiscall boost::asio::ssl::detail::engine::map_error_code(class boost::system::error_code &)const " (?map_error_code@engine@detail@ssl@asio@boost@@QBEABVerror_code@system@5@AAV675@@Z) で参照されました。    cppnetlib-client-connections.lib(client.obj)    
エラー 57  error LNK2019: 未解決の外部シンボル _BIO_ctrl_pending が関数 "private: enum boost::asio::ssl::detail::engine::want __thiscall boost::asio::ssl::detail::engine::perform(int (__thiscall boost::asio::ssl::detail::engine::*)(void *,unsigned int),void *,unsigned int,class boost::system::error_code &,unsigned int *)" (?perform@engine@detail@ssl@asio@boost@@AAE?AW4want@12345@P812345@AEHPAXI@Z0IAAVerror_code@system@5@PAI@Z) で参照されました。    cppnetlib-client-connections.lib(client.obj)
エラー 43  error LNK2019: 未解決の外部シンボル _BIO_free が関数 "public: __thiscall boost::asio::ssl::detail::engine::~engine(void)" (??1engine@detail@ssl@asio@boost@@QAE@XZ) で参照されました。    cppnetlib-client-connections.lib(client.obj)    

Could you tell me what I'm missing? I tried to add more libs to the project, but it still didn't work.


回答1:


I should've got to add these two library.

libeay32.lib ssleay32.lib




回答2:


I ran into the same problem, except i fixed it by using the WIN32 version of SSL instead of the X64 version.



来源:https://stackoverflow.com/questions/22682678/how-to-use-cpp-netlib-with-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!