我想遍歷目錄並打印從根開始的所有文件的名稱。遞歸掃描文件的目錄
這是我在程序中使用Boost::Filesystem
(1.52.0)寫的一小段代碼。
void testApp::getNames(const string& dirPath, string& fileExtension)
{
namespace fs = boost::filesystem;
namespace sys = boost::system;
fs::path filePath(dirPath);
for(fs::recursive_directory_iterator dir(filePath), dir_end; dir!=dir_end ;++dir)
{
cout<<*dir;
}
}
在嘗試編譯這個,奇怪的是我正在建立一個指向上下面的代碼片段path.hpp
文件錯誤:
static const codecvt_type& codecvt()
{
return *wchar_t_codecvt_facet();
}
,我得到的錯誤是undefined reference to boost::filesystem3::path::wchar_t_codecvt_facet()'|
我在Ubuntu 12.10爲我的項目使用Codeblocks IDE。
這是一個鏈接器錯誤 - 文件系統庫包含必須編譯和鏈接的組件 - 它不是僅包含頭文件的庫。 –
您可以指向必須使用的鏈接器標誌/ – user1240679
是不是隻要添加-lboost_filesystem? – daramarak