简体   繁体   English

使用C ++和Boost创建目录时出错

[英]Error when creating a directory with C++ and Boost

I'm trying to create a directory in C++ (compiling with Clang) on Mac Yosemite with Boost (Boost was installed via Macports). 我正在尝试使用Boost(Boost通过Macports安装)在Mac Yosemite上用C ++(使用Clang编译)创建目录。 This is what my code looks like: 这是我的代码如下所示:

#include <boost/filesystem.hpp> // header at top of file

boost::filesystem::path path("/Users/u5305887/Desktop/ti"); // code in main function
boost::filesystem::create_directories( path );

However, when I compile it, I get the following error: 但是,当我编译它时,出现以下错误:

Undefined symbols for architecture x86_64: "boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)" 架构x86_64的未定义符号:“ boost ::文件系统:: detail :: create_directories(boost ::文件系统:: path const&,boost :: system :: error_code *)”

I've been trying to Google this error but I can't seem to find any way to fix it. 我一直在尝试Google这个错误,但似乎找不到任何解决方法。 I've double checked my code against a few tutorials and can't see where I've gone wrong. 我根据一些教程仔细检查了我的代码,看不到哪里出了问题。

You need to link against the boost libraries. 您需要链接到Boost库。 Eg for clang you'd add 例如您要添加的c

-lboost_system -lboost_filesystem

to your linking step. 到您的链接步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM