我尝试在gcc 6.0中使用新的c ++ 1z功能实际开发.
如果我尝试这个小例子:
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p1 = "/home/pete/checkit";
std::cout << "p1 = " << p1 << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我有:
/opt/linux-gnu_6-20151011/bin/g++ --std=c++1z main.cpp -O2 -g -o go /tmp/ccaGzqFO.o: In function \`std::experimental::filesystem::v1::__cxx11::path::path(char const (&) [36])': /opt/linux-gnu_6-20151011/include/c++/6.0.0/experimental/bits/fs_path.h:167: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()' collect2: error: ld returned 1 exit status
gcc版本是快照linux-gnu_6-20151011
任何提示如何链接新的c ++ 1z功能?
我正在尝试使用 Meson 构建系统构建一段使用新的 C++17 文件系统库的 C++ 代码。
这是meson.build涉及的文件:
if not compiler.has_header('filesystem') # This is OK
warning('The compiler has no <filesystem> header file')
endif
filesystem_dep = dependency('libc++fs', modules : ['filesystem'])
test_exe = executable('test', test_src,
include_directories : include_dirs,
dependencies : filesystem_dep
)
Run Code Online (Sandbox Code Playgroud)
如果使用 boost::filesystem 库,这应该是正确的语法:
filesystem_dep = dependency('boost', modules : ['filesystem'])
Run Code Online (Sandbox Code Playgroud)
如何指定我想要标准 C++ 库中包含的版本?这是我尝试过但没有成功的方法:'libc++fs'、'stdlib'、'stdc++'、'libc++'、'c++'、'c++17'。
这是我从 Meson 收到的错误消息:
src/meson.build:33:0: 错误: 未找到本机依赖项“libc++fs”
我目前使用的编译器是LLVM/clang。