多くの人 (例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.
すべてをコンパイルする小さなシェル スクリプトを次に示します。他のバリエーションもいくつか試しました。
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 ..