configure: error: cannot figure out how to use std::filesystem #27148

issue pinheadmz opened this issue on February 23, 2023
  1. pinheadmz commented at 4:05 PM on February 23, 2023: member

    Got this error from configure when trying to build from tag v24.0.1 on Ubuntu 18.

    At first my gcc was version gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) so I tried installing clang 10: clang version 10.0.0-4ubuntu1~18.04.2 and linked to CXX, etc... still got the same error.

    $ uname -a
    Linux party 4.15.0-163-generic [#171](/bitcoin-bitcoin/171/)-Ubuntu SMP Fri Nov 5 11:55:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
    
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.4 LTS
    Release:        18.04
    Codename:       bionic
    

    Complete output:

    $ ./configure --without-gui --with-incompatible-bdb
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking whether to enable maintainer-specific portions of Makefiles... yes
    checking whether make supports nested variables... (cached) yes
    checking whether the C++ compiler works... yes
    checking for C++ compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether /usr/bin/clang++-10 accepts -g... yes
    checking for style of include used by make... GNU
    checking dependency style of /usr/bin/clang++-10... gcc3
    checking whether /usr/bin/clang++-10 supports C++17 features with -std=c++17... yes
    checking whether std::filesystem can be used without link library... no
    checking whether std::filesystem needs -lstdc++fs... no
    checking whether std::filesystem needs -lc++fs... configure: error: in `/root/bitcoin':
    configure: error: cannot figure out how to use std::filesystem
    See `config.log' for more details
    
  2. pinheadmz added the label Bug on Feb 23, 2023
  3. fanquake commented at 4:07 PM on February 23, 2023: member

    ./configure --without-gui --with-incompatible-bdb

    I see clang is being used in the output, but how are you passing clang through? CC=clang=10 CXX=clang++? What is the actual output in config.log?

  4. pinheadmz commented at 4:12 PM on February 23, 2023: member

    yeah:

    $ env | grep clang
    CC=/usr/bin/clang-10
    CXX=/usr/bin/clang++-10
    

    This is the relevant chunk from config.log:

    
    configure:4823: checking whether /usr/bin/clang++-10 supports C++17 features with -std=c++17
    configure:5619: /usr/bin/clang++-10 -std=c++17 -c -g -O2  conftest.cpp >&5
    configure:5619: $? = 0
    configure:5628: result: yes
    configure:6565: checking whether std::filesystem can be used without link library
    configure:6581: /usr/bin/clang++-10 -std=c++17 -o conftest -g -O2   conftest.cpp  >&5
    conftest.cpp:11:12: fatal error: 'filesystem' file not found
      #include <filesystem>
               ^~~~~~~~~~~~
    1 error generated.
    configure:6581: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME "Bitcoin Core"
    | #define PACKAGE_TARNAME "bitcoin"
    | #define PACKAGE_VERSION "24.0.1"
    | #define PACKAGE_STRING "Bitcoin Core 24.0.1"
    | #define PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues"
    | #define PACKAGE_URL "https://bitcoincore.org/"
    | #define HAVE_CXX17 1
    | /* end confdefs.h.  */
    |
    |   #include <filesystem>
    |
    |   namespace fs = std::filesystem;
    |
    |   int main() {
    |     (void)fs::current_path().root_name();
    |     return 0;
    |   }
    |
    configure:6588: result: no
    configure:6592: checking whether std::filesystem needs -lstdc++fs
    configure:6607: /usr/bin/clang++-10 -std=c++17 -o conftest -g -O2   conftest.cpp  -lstdc++fs >&5
    conftest.cpp:11:12: fatal error: 'filesystem' file not found
      #include <filesystem>
               ^~~~~~~~~~~~
    1 error generated.
    configure:6607: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME "Bitcoin Core"
    | #define PACKAGE_TARNAME "bitcoin"
    | #define PACKAGE_VERSION "24.0.1"
    | #define PACKAGE_STRING "Bitcoin Core 24.0.1"
    | #define PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues"
    | #define PACKAGE_URL "https://bitcoincore.org/"
    | #define HAVE_CXX17 1
    | /* end confdefs.h.  */
    |
    |   #include <filesystem>
    |
    |   namespace fs = std::filesystem;
    |
    |   int main() {
    |     (void)fs::current_path().root_name();
    |     return 0;
    |   }
    configure:6614: result: no
    configure:6616: checking whether std::filesystem needs -lc++fs
    configure:6632: /usr/bin/clang++-10 -std=c++17 -o conftest -g -O2   conftest.cpp  -lc++fs >&5
    conftest.cpp:11:12: fatal error: 'filesystem' file not found
      #include <filesystem>
               ^~~~~~~~~~~~
    
  5. pinheadmz commented at 4:16 PM on February 23, 2023: member

    Errors in config.log look the same with gcc 7 too:

    checking whether g++ supports C++17 features with -std=c++17... yes
    checking whether std::filesystem can be used without link library... no
    checking whether std::filesystem needs -lstdc++fs... no
    checking whether std::filesystem needs -lc++fs... configure: error: in `/root/bitcoin':
    configure: error: cannot figure out how to use std::filesystem
    See `config.log' for more details
    
  6. hebasto commented at 4:16 PM on February 23, 2023: member

    yeah:

    $ env | grep clang
    CC=/usr/bin/clang-10
    CXX=/usr/bin/clang++-10
    

    You're still using an old libstdc++.

  7. maflcko commented at 4:19 PM on February 23, 2023: member

    gcc 7 doesn't have filesystem. You can try CC=clang-10 CXX="clang++-10 -stdlib=libc++"

  8. fanquake commented at 4:22 PM on February 23, 2023: member

    This is the relevant chunk from config.log:

    Installing libstdc++-8-dev will solve the problem.

  9. pinheadmz commented at 4:23 PM on February 23, 2023: member

    Installing libstdc++-8-dev will solve the problem.

    YES! Thanks. Add to docs ?

  10. hebasto commented at 4:28 PM on February 23, 2023: member

    Add to docs ?

    Probably, it does not worth, considering that Ubuntu 18 is about to reach "End of Standard Support" soon.

  11. hebasto removed the label Bug on Feb 23, 2023
  12. hebasto added the label Build system on Feb 23, 2023
  13. hebasto added the label Questions and Help on Feb 23, 2023
  14. pinheadmz closed this on Feb 23, 2023

  15. pinheadmz added the label Docs on Mar 27, 2023
  16. wangtao19911111 commented at 8:35 AM on May 31, 2023: none

    This is the relevant chunk from config.log:

    Installing libstdc++-8-dev will solve the problem.

    how to install this lib?

  17. maflcko commented at 10:55 AM on May 31, 2023: member

    @wangtao19911111 The minimum required version is installed by default with g++, if you use the latest LTS release of your operating system.

  18. bitcoin locked this on May 30, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me