很多人(例如1、2)都问过如何去std::filesystem::directory_iterator
上班,但我读完这些后仍然遇到麻烦。
我正在尝试构建一个小型静态库。在将目录迭代器添加到一些源文件中后,我更新了我的 gcc,并添加了-lstdc++fs
位,但似乎没有任何效果,因为我不断收到错误消息
fatal error: filesystem: No such file or directory
#include <filesystem>
如果我输入gcc --version
,我会得到
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
如果我打字gcc-8 --version
,我会得到
gcc-8 (Ubuntu 8.1.0-1ubuntu1) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
这是我编译所有内容的小 shell 脚本。我也尝试了其他一些变化。
EIGEN=/usr/include/eigen3
cd ./bin
for file in ../src/*cpp; do
g++ -std=c++11 -fPIC -c -I$EIGEN -I../include -O3 $file "-lstdc++fs"
done
ar crv libfoo.a *.o
cd ..