filesystem 新特特性怎么在mac下不能用?
如果在windows 和 max os下边使用filesystem 我现在在vs2017上边使用 filesystem一切正常,但是在xcode 里边就不对,找不到头文件。
解决方法: 在mac os 下用 xcode 里边用 boost::filesystem 替代。
1. 在mac os 里边 安装 boost
I followed henrikstroem's great post, like this:
Install via homebrew, took less than 3 minutes
mac:~ woz$ brew install boost
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/boost-1.57.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.57.0.yosemite.bottle.tar.gz
? /usr/local/Cellar/boost/1.57.0: 10572 files, 439M
mac:~ woz$
Create symlink in your homedir
mac:~ woz$ cd
mac:~ woz$ ln -s /usr/local/Cellar/boost/1.57.0 boost_1_57_0
mac:~ woz$
Inside Xcode refer to the just created symlink like this
For the Header Search Paths
use $(HOME)/boost_1_57_0/include
For the Library Search Paths
use $(HOME)/boost_1_57_0/lib
2. 在代码里这么写就可以了
:
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
结果: 问题奇怪,在mac 下就是找不到头文件,现在用上边的方法可以通过了,但原因未知。
感觉现代的c++真是好用,有了这些东东,就可以横行天下了 ^-^。