2012-02-20 89 views
5

我試圖編譯Boost 1.47 ASIO SSL服務器和客戶端示例。我可以成功地將Boost加入到我的項目中,但我無法加入OpenSSL。當我嘗試添加它,我得到的錯誤:使用Visual Studio 2010和OpenSSL提升SSL

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 " ([email protected][email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@QA[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]) 
1>C:\Users\Epicism\Documents\Visual Studio 2010\Projects\SSLServer\Debug\SSLServer.exe : fatal error LNK1120: 12 unresolved externals 
1> 
1>Build FAILED. 

我曾嘗試加入目錄C:\的OpenSSL的Win32 \ LIB \,C:\的OpenSSL的Win32 \ LIB \ VC \,C:\ OpenSSL的-Win32 \ lib \ VC \ static,C:\ OpenSSL-Win32 \ bin,C:\ OpenSSL-Win32 \ include包含到Project-> General Properties-> Linker-> Additional Library Directories using the openssl pre-compiled libraries(http: //www.openssl.org/related/binaries.html)。我也嘗試用相同的錯誤編譯OpenSSL。我真的很茫然,我已經試過我已搜查谷歌了一千倍的一切,試圖IRC,目錄,我能想到的每一個組合...

我的設置是: Windows 7的64位 Windows Visual Studio 2010 64位 Boost 1.47 OpenSSL 1.0.0E和G C/C++其他包含目錄:C:\ Program Files(x86)\ boost \ boost_1_47; C:\ openssl \ include \; C:\ OpenSSL- Win32 \ lib;%(AdditionalIncludeDirectories) Project-> General Properties-> Linker-> Additional Library Directories:C:\ Program Files(x86)\ boost \ boost_1_47 \ lib; C:\ openssl \ lib; C:\ openssl; %(AdditionalLibraryDirectories) - 我已經嘗試將每個目錄添加到此屬性以及....

現在我只是想編譯在VS C++控制檯項目如下:

// SSLServer.cpp:定義控制檯應用程序的入口點。 //

#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; 
} 

在此先感謝。

+0

是的,我也是我有這個問題,因爲welll – jzeus 2012-06-30 06:01:07

+0

我也有這個問題。有人設法弄清楚了嗎?如果是的話請回傳。下面試過弗雷澤的建議,但仍然有問題。 – 2013-01-12 00:55:21

回答

10

看起來您在64位機器上使用的是32位版本的OpenSSL。

嘗試從http://www.slproweb.com/products/Win32OpenSSL.html

下載64位版本(Win64中的OpenSSL v1.0.0g)後所安裝的(如果你使用默認路徑),你應該有一個C:\OpenSSL-Win64文件夾。

您應該添加:

  • C:\OpenSSL-Win64\include到您的附加包含目錄
  • C:\OpenSSL-Win64\lib\VC\staticC:\OpenSSL-Win64\lib\VC取決於你是否希望靜態庫的附加庫目錄或分別的dll
  • libeay32<XXX>.libssleay32<XXX>.lib到其他依賴關係<XXX>與您的任何設置匹配[C/C++]->[Code Generation]->[Runtime Library]
+0

如何通過命令行(例如,通過Jamfile?)與Visual Studio 2015和Boost.Build配合使用? – 2016-10-02 00:09:01

3

我設法通過連接32位版本的Boost庫和32位版本的OpenSSL來建立上面的小程序。您還需要32位版本的redistributables。該錯誤出現在Boost版本1.51和1.52中,這是我測試的唯一版本。

我相信ASIO庫的64位版本存在一個錯誤。儘管可能是某種配置問題影響了其他許多配置問題。我提交了一個關於該問題的Boost錯誤報告。

0

我會見了類似的問題(VS2010),解決方法:

1)屬性 - > C/C++ - >通用>附加包含目錄:yourpath \ boost_1_58_0 \ boost_1_58_0(I使用1.58.0版)

2)屬性 - >鏈接 - >通用>附加庫目錄: yourpath \ boost_1_58_0 \ boost_1_58_0 \階段\ lib中

3)屬性 - >鏈接 - >輸入 - >附加的依賴關係: libeay32 .lib ssleay32.lib

這兩個.lib文件是從openssl安裝目錄複製的。