dimanche 23 septembre 2018

`std::filesystem::directory_iterator` linker issue

Many people (e.g 1, 2) have asked about how to get std::filesystem::directory_iterator to work, but I'm still having trouble after I've read those.

I am trying to build a small static library. After adding in the directory iterator into some source files, I updated my gcc, and added the -lstdc++fs bit, but nothing seems to work.

If I type gcc --version, I get

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.

And if I type gcc-8 --version I get

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.

Here's my little shell script that compiles everything. I've tried a few other variations, too.

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 ..

Aucun commentaire:

Enregistrer un commentaire