简体   繁体   中英

How to use Boost.Filesystem on Linux?

I've written a simple code which create folder. The problem is that I can't compile it. The code is below:

#include <iostream>
#include <boost/filesystem.hpp>
int main()
{
  boost::filesystem::create_directories("/tmp");
  return 0;
}

Compilation:

g++ createFolder.cpp -std=c++0x -lboost_system -o createFolder

I have got errors:

collect2: ld returned 1 exit status

How to correct the compilation process to run this program.

尝试将boost-filesystem添加到链接器:

g++ createFolder.cpp -std=c++0x -lboost_system -lboost_filesystem -o createFolder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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