网上可参考的文章已经有很多很详细了,主要参考:

http://hi.baidu.com/chinacharis/blog/item/f58bef76e02ede12b051b92a.html 编译openssl

http://www.boost.org/doc/libs/1_39_0/more/getting_started/windows.html 编译boost boost.org 1.39.0版本的英文参考

http://hi.baidu.com/chinacharis/blog/item/7debed65c72917f9f7365413.html 编译libtorrent

 

但是有些需要自己注意的地方:

编译boost 的时候:

  •  出现error,修改了ms目录下的ntdll.mak文件,把-w3修改为-w0

编译libtorrent的时候:

 

  • 报错1:GeoIP.c :没找到"libtorrent/GeoIP.cpp" ,增加预处理器定义:WITH_SHIPPED_GEOIP_H

 

 

  •  报错2: \boost_1_39_0\boost\asio\ssl\detail\openssl_context_service.hpp(74) : error C2440: “=”: 无法从“const SSL_METHOD *”转换为“SSL_METHOD *” 所以我将openssl_context_service.hpp中的那个变量声明前加了const修饰符( const ::SSL_METHOD* ssl_method = 0;),编译就通过了

编译通过生成exe成功。

运行时报错:找不到:libeay32.dll ssleay32.dll,于是 添加 libeay32.dll ssleay32.dll ,openssl.exe 放到exe同样的目录下。


 

 使用release 版本,之前用debug 弄了几天都是运行时抛出异常,具体如下:

  • 有时文件作为输入参数时,只是输出文件名,然后退出。
  • 文件夹作为输入参数时,抛出异常,输出come to error,然后退出。
  • debug 版本在make_torrent的example 的 addfile 出错,最终跳到boost 的filesystem的源码里面(有时是is_directory函数)

 

路径含有中文是会出错的, http://www.cppblog.com/hblhs/archive/2008/10/21/64597.html给出了解决方案(但经测试,不完全正确,需要做以下更改)

std::wstring safe_convert(std::string const& s)
 {
  
/*try
  {
   return libtorrent::utf8_wchar(s);
  }
  catch (std::exception)
  {
   std::wstring ret;
   const char* end = &s[0] + s.size();
   for (const char* i = &s[0]; i < end;)
   {
    wchar_t c = '.';
    int result = std::mbtowc(&c, i, end - i);
    if (result > 0) i += result;
    else ++i;
    ret += c;
   }
   return ret;
  }
*///wchar_t wc;
  wchar_t *wcs = new wchar_t[s.size()];
  
  setlocale(LC_CTYPE, 
"chs");  //原setlocale(LC_CTYPE, ""); 
 
  mbstowcs(wcs, s.c_str(), s.size() 
+ 1); //参考的文章缺少这个+1
 
  std::wstring newword(wcs);

  delete[] wcs;
  
return newword;
 }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-05-18
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2021-09-17
  • 2021-10-16
  • 2021-10-07
  • 2021-04-18
  • 2021-06-22
  • 2021-05-14
相关资源
相似解决方案