2014-03-12 39 views
3

我試圖使用Boost來獲得當前的臨時文件夾:提高文件系統suprious錯誤(temp_directory_path返回<Bad Ptr>)

boost::system::error_code error; 
auto tmp_path = boost::filesystem::temp_directory_path(error); 

if (boost::system::errc::success != error.value()) 
{ 
    std::cout << error.message() << std::endl; 
} 

雖然視覺工作室期間2013調試會話調查tmp_path的價值似乎值的tmp_path不正確 - VS顯示{m_pathname=<Bad Ptr>}

下面的代碼也將失敗與異常「字符串太長」,這可能涉及到的問題:

std::string tmp_file_str("test"); 
boost::filesystem::path tmp_file(tmp_file_str); 

升壓與MSVC的工具集本地編譯:

cd boost-folder 
bootstrap 
.\b2 toolset=msvc-12.0 variant=release link=static,shared threading=multi --with-chrono --with-date_time --with-filesystem --with-system --with-thread --with-test 

環境:

  • Windows 8.1版本6.3.9600 Build 9600 x64
  • 的Visual Studio 2013版本12.0.30110.00更新1

回答

1

錯誤是因爲兩個因素的巧合:動態和自動加載無需連接

  • Boost庫(BOOST_ALL_DYN_LINK; BOOST_ALL_NO_LIB)
  • 鏈接boost庫處於發佈模式,但項目處於調試模式

variant=release,debug重新編譯增強,特定在鏈接器屬性中添加-gd-庫,並將-gd- dll添加到解決問題的路徑中。

相關問題