0

I having problem with filesystems library. I have seen many solutions from SO and multiple other forums, but none of them works for me. (I will add list most of them bellow)

System specs:

WSL - Ubuntu 18.04 on Windows 10 build 19041

G++:

g++-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0

Linker error: the message is prety chaotic so I will show just the important parts of error message and the complete error message will be bellow.

undefined reference `std::experimental::filesystem::v1::file_size(...)
undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()

From what I see the header file is here, but the source file with definitons is not included.

I have tried:

  1. Adding -lstdc++fs along with -std=c++17
  2. Using both #include <filesystems> and #include <experimental/filesystems> - in first case it doesn't even see the header file of the lib. I even tried some other -std=... flags that I can't name right now.

The complete error: https://pastebin.com/HuePgrMw

Pavel B.
  • 843
  • 1
  • 7
  • 17
  • 1
    Please give all information here, including a [mre]. Review [ask] please. – Yunnosch May 19 '21 at 20:27
  • @Yunnosch problem is this will be system and compiler specific... even if I gave you the entire source code. There is no garantie you would have this problem. – Pavel B. May 19 '21 at 20:29
  • @SergeyA I looked into ```/usr/lib/gcc/8/``` and the library is here... I forgot this one thanks. – Pavel B. May 19 '21 at 20:31
  • Please read [mre] again. There is an important difference between "the entire source code" and MRE. I assume you have read that already, seeing your reputation, that is why I ask you to review it, and [ask]. – Yunnosch May 19 '21 at 20:38
  • @Yunnosch Problem is my problem is not in code. The problem lies in linking the library, hence the ```undefined reference```. I give you alredy all information that I have you have. If you want code example there you have one https://pastebin.com/rXqzfeZB even tho it wont help you... compile it using the comand on the first line. then there is 2 includes which one you should use depend on your g++ version... in my case there will be an error. In your case it could just compile... that's why giving MRE is not an option since it's not 100% Reproductible. – Pavel B. May 19 '21 at 21:42
  • If you consider neither of the two answers you got to be an answer then you should explain why not. – Yunnosch May 19 '21 at 22:02
  • @Yunnosch I fixed it... by removing all my g++ and gcc versions and the added only g++-8 and set it as default. It started magicaly working... But what was wrong... I don't know. None of them worked for me, I tryed all this before posting this question and it didn't work... – Pavel B. May 20 '21 at 07:12

0 Answers0