【问题标题】:Error when creating a directory with C++ and Boost使用 C++ 和 Boost 创建目录时出错
【发布时间】:2015-10-09 01:44:05
【问题描述】:

我正在尝试使用 Boost 在 Mac Yosemite 上使用 C++(使用 Clang 编译)创建一个目录(Boost 是通过 Macports 安装的)。这是我的代码的样子:

#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 );

但是,当我编译它时,我收到以下错误:

架构 x86_64 的未定义符号: “boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)”

我一直在尝试用 Google 搜索此错误,但似乎找不到任何解决方法。我根据一些教程仔细检查了我的代码,但看不出哪里出错了。

【问题讨论】:

  • soooo “不创建目录时出错”,实际上
  • 好吧,我猜尝试创建目录时出错。

标签: c++ macos boost directory macports


【解决方案1】:

您需要链接到 boost 库。例如。对于铿锵声,你会添加

-lboost_system -lboost_filesystem

到您的链接步骤。

【讨论】:

  • 啊该死的我忘了把它添加到我的 makefile 中,非常感谢!
猜你喜欢
  • 2017-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多