2
我在使用這段代碼的問題:的boost ::文件系統:: create_symlink不支持
boost::filesystem::create_directory_symlink: The request is not supported: "C:\\Users\\Administrator\\Desktop\\test.txt", "C:\\Users\\Administrator\\Desktop\\test_symlink.txt"
:
#include <iostream>
#include <boost/filesystem.hpp>
namespace bfs = boost::filesystem;
int main(int argc, char **argv)
{
try
{
bfs::create_symlink("C:\\Users\\Administrator\\Desktop\\test.txt",
"C:\\Users\\Administrator\\Desktop\\test_symlink.txt");
}
catch (std::exception& e)
{
std::cout << e.what() << std::endl;
}
return 0;
}
在調用一個異常create_symlink
功能結果正在與消息拋出
我掠過Boost.Filesystem的的operations.cpp
文件,並發現這一點:
BOOST_FILESYSTEM_DECL
void create_symlink(const path& to, const path& from, error_code* ec)
{
# if defined(BOOST_WINDOWS_API) && _WIN32_WINNT < 0x0600 // SDK earlier than Vista and Server 2008
error(true, error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()), to, from, ec,
"boost::filesystem::create_directory_symlink");
# else
# if defined(BOOST_WINDOWS_API) && _WIN32_WINNT >= 0x0600
// see if actually supported by Windows runtime dll
if (error(!create_symbolic_link_api,
error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()),
to, from, ec,
"boost::filesystem::create_symlink"))
return;
# endif
error(!BOOST_CREATE_SYMBOLIC_LINK(from.c_str(), to.c_str(), 0),
to, from, ec, "boost::filesystem::create_symlink");
# endif
}
這表明編譯Boost時我的_WIN32_WINNT
可能不夠高。我已經去了並且編譯了Boost.Filesystem,但是這次添加了define=_WIN32_WINNT=0x601
,並且我仍然收到一個帶有相同消息的異常。我也嘗試過定義BOOST_WINDOWS_API
which seems to be deprecated,但那樣會導致編譯錯誤。
我從mingw-builds使用Windows 7,Boost 1.54.0和MinGW-x64-4.8.1-posix-seh-rev4
。