我想遍历目录并打印从根开始的所有文件的名称。递归扫描文件的目录
这是我在程序中使用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