1

I have "Raspberry Pi 3 Model B" with "Raspbian Buster with desktop" installed on SD-card.

I installed all the necessary to compile with g++:

gcc (Raspbian 8.3.0-6+rpi1) 8.3.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.

I created a small test file (test.cpp):

#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
    for(fs::path p : {"/var/tmp/example.txt", "/", "/var/tmp/."})
        std::cout << "The parent path of " << p
                  << " is " << p.parent_path() << '\n';
}

and compiled with the command:

g++ -std=c++17 -Wall -Wextra -pedantic-errors test.cpp -o test

but compilation fail with error:

/usr/bin/ld: /tmp/cckH4cTy.o: in function `main':
test.cpp:(.text+0xa4): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
/usr/bin/ld: /tmp/cckH4cTy.o: in function `std::filesystem::__cxx11::path::path<char const*, std::filesystem::__cxx11::path>(char const* const&, std::filesystem::__cxx11::path::format)':
test.cpp:(.text._ZNSt10filesystem7__cxx114pathC2IPKcS1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5IPKcS1_EERKT_NS1_6formatE]+0x70): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status

How to solve ?

debugasm
  • 11
  • 1

0 Answers0