[filesystem] why is this file not found?
I'm having difficulty using boost/filesystem.hpp on a simple test example. If I understand things correctly, this code should see if it can find the files called "test_file" and "test_file2" in the current directory.
```
#include
First file not found Second file not found
I expected only the second file to be not found. I arrived at this question because exists(file1) was returning false when I thought it should return true, and I traced the issue back to this check. I've also tried this example with an absolute path, and the results were the same. This is using Boost 1.81 installed via macports on a mac with OS 12.5.1 (so slightly out-of-date OS). Is this a mac issue or am I missing something in my code?
Hi Michael,
the result is
First file not found Second file not found
I expected only the second file to be not found.
This kind of issue can occur when the compiler used to compile libboost_filesystem is different from the one used to compile the .cpp file. (Though a link error often arises in these situations, this time it resulted in erroneous behaviors.) When using Homebrew's libboost_filesystem, which is compiled with Clang (or more precisely, Apple Clang), a similar issue occurred when compiling the .cpp file with g++-12. When I used the `clang++` command instead of the `g++-12` command, it worked correctly. Regards, Michel
participants (2)
-
Michael Burr
-
Michel Morin