使用 Visual Studio 2010 和 OpenSSL 提升 SSL [英] Boost SSL with Visual Studio 2010 and OpenSSL

查看:32
本文介绍了使用 Visual Studio 2010 和 OpenSSL 提升 SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译 Boost 1.47 ASIO SSL 服务器和客户端示例.我可以成功地将 Boost 合并到我的项目中,但我不能合并 OpenSSL.当我尝试添加它时,出现错误:

I'm trying to compile the Boost 1.47 ASIO SSL server and client examples. I can sucessfully incorporate Boost into my project, but I cannot incorporate OpenSSL. When I try to add it I get the errors:

1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_reason_error_string referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall boost::asio::error::detail::ssl_category::message(int)const " (?message@ssl_category@detail@error@asio@boost@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_id_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_library_init referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ENGINE_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CONF_modules_unload referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_cleanup_all_ex_data referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _EVP_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_remove_state referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_free_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init@openssl_init_base@detail@ssl@asio@boost@@QAE@XZ)
1>C:UsersEpicismDocumentsVisual Studio 2010ProjectsSSLServerDebugSSLServer.exe : fatal error LNK1120: 12 unresolved externals
1>
1>Build FAILED.

我尝试添加目录 C:OpenSSL-Win32lib, C:OpenSSL-Win32libVC, C:OpenSSL-Win32libVCstatic, C:OpenSSL-Win32in, C:OpenSSL-Win32include 到 Project->General Properties->Linker->Additional Library Directories 使用 openssl 预编译库 (http://www.openssl.org/related/binaries.html).我也尝试过自己编译 OpenSSL 时遇到相同的错误.我真的不知所措,我已经尝试了我在谷歌上搜索过的所有东西大约一千次,尝试了 IRC,我能想到的所有目录组合......

I have tried adding the directory C:OpenSSL-Win32lib, C:OpenSSL-Win32libVC, C:OpenSSL-Win32libVCstatic, C:OpenSSL-Win32in, C:OpenSSL-Win32include to Project->General Properties->Linker->Additional Library Directories using the openssl pre-compiled libraries (http://www.openssl.org/related/binaries.html). I have also tried compiling OpenSSL myself with the same errors. I'm really at a loss, I have tried everything I have searched Google about a thousand times, tried IRC, every combination of directories I can think of...

我的设置是:视窗 7 64 位视窗 Visual Studio 2010 64 位提升 1.47OpenSSL 1.0.0E 和 GC/C++ 附加包含目录:C:Program Files (x86)oostoost_1_47;C:opensslinclude;C:OpenSSL-Win32lib;%(AdditionalIncludeDirectories)项目->通用属性->链接器->附加库目录:C:Program Files (x86)oostoost_1_47lib;C:openssllib;C:openssl;%(AdditionalLibraryDirectories)- 我也尝试将每个目录添加到此属性中....

My setup is: Windows 7 64-bit Windows Visual Studio 2010 64 bit Boost 1.47 OpenSSL 1.0.0E and G C/C++ Additional Include Directories: C:Program Files (x86)oostoost_1_47;C:opensslinclude;C:OpenSSL-Win32lib;%(AdditionalIncludeDirectories) Project->General Properties->Linker->Additional Library Directories: C:Program Files (x86)oostoost_1_47lib;C:openssllib;C:openssl;%(AdditionalLibraryDirectories) - I've tried adding every directory to this property as well....

现在我只是想在 VS C++ 控制台项目中编译以下内容:

Right now I'm just trying to compile the following in a VS C++ console project:

//SSLServer.cpp : 定义控制台应用程序的入口点.//

// SSLServer.cpp : Defines the entry point for the console application. //

#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

提前致谢.

推荐答案

看起来您正在 64 位机器上使用 32 位版本的 OpenSSL.

Looks like you're using the 32-bit version of OpenSSL on a 64-bit machine.

尝试从 http://下载 64 位版本 (Win64 OpenSSL v1.0.0g)www.slproweb.com/products/Win32OpenSSL.html

安装后(如果您使用默认路径),您应该有一个 C:OpenSSL-Win64 文件夹.

After that's installed (if you use default paths), you should have a C:OpenSSL-Win64 folder.

您应该添加:

  • C:OpenSSL-Win64include 到您的附加包含目录
  • C:OpenSSL-Win64libVCstaticC:OpenSSL-Win64libVC 到您的附加库目录,具体取决于您是否需要分别是静态库或 dll
  • libeay32.libssleay32.lib 到附加依赖项,其中 匹配您拥有的任何设置for [C/C++]->[代码生成]->[运行库]
  • C:OpenSSL-Win64include to your Additional Include Directories
  • C:OpenSSL-Win64libVCstatic or C:OpenSSL-Win64libVC to your Additional Library Directories depending on whether you want the static libs or the dlls respectively
  • libeay32<XXX>.lib and ssleay32<XXX>.lib to Additional Dependencies where <XXX> matches whatever setting you have for [C/C++]->[Code Generation]->[Runtime Library]

这篇关于使用 Visual Studio 2010 和 OpenSSL 提升 SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆