Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
1627 Discussions

dpcpp using C++17 header

breyerml
Novice
3,113 Views

Given the following code:

 

#include <filesystem>

int main() {
    return 0;
}

 

 Trying to compile it on the devlcoud using :

 

dpcpp -std=c++17 main.cpp

 

gives the following error:

 

main.cpp:1:10: fatal error: 'filesystem' file not found
#include <filesystem>
         ^~~~~~~~~~~~
1 error generated.

 

My guess is that dpcpp somehow uses parts of GCC 7.4.0 where <filsystem> wasn't implemented.

Is there a way to get this working? (The same problem appears for example with <charconv> too)

0 Kudos
1 Solution
RahulV_intel
Moderator
3,088 Views

Hi,

 

DPC++ does not have any dependency on GCC 7.4.0.

 

Kindly refer to the software/hardware requirements here:

https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements-beta.html

 

Any GCC version >= 7.0 should suffice. However, FPGA development requires GCC 7.4.0.

 

In my development environment, I have GCC 8.4.0 and I do not see any error if I include the header <filesystem> in my code.

 

However, there is a workaround for GCC 7 versions. The <filesystem> header file is present as a part of <experimental/filesystem>. 

Refer to the code snippet below:

#include <experimental/filesystem>

namespace fs = std::experimental::filesystem;

int main() {
    return 0;
}

//To compile and run
dpcpp file_name.cpp -lstdc++fs -o fs && ./fs

 

For GCC versions 8 and above, <filesystem> can be included directly along with -std=c++17 flag (just like you tried previously). 

 

Regards,

Rahul

View solution in original post

8 Replies
RahulV_intel
Moderator
3,089 Views

Hi,

 

DPC++ does not have any dependency on GCC 7.4.0.

 

Kindly refer to the software/hardware requirements here:

https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements-beta.html

 

Any GCC version >= 7.0 should suffice. However, FPGA development requires GCC 7.4.0.

 

In my development environment, I have GCC 8.4.0 and I do not see any error if I include the header <filesystem> in my code.

 

However, there is a workaround for GCC 7 versions. The <filesystem> header file is present as a part of <experimental/filesystem>. 

Refer to the code snippet below:

#include <experimental/filesystem>

namespace fs = std::experimental::filesystem;

int main() {
    return 0;
}

//To compile and run
dpcpp file_name.cpp -lstdc++fs -o fs && ./fs

 

For GCC versions 8 and above, <filesystem> can be included directly along with -std=c++17 flag (just like you tried previously). 

 

Regards,

Rahul

breyerml
Novice
3,080 Views

After installing GCC 9.3.0 and setting 

--gcc-toolchain

to the installation directory it finally works.

Thanks for your answer.

 

0 Kudos
breyerml
Novice
3,064 Views

Interestingly even with GCC 9.3.0 I'm unable to link against <filesystem>. Using <experimental/filesystem> however works.

0 Kudos
RahulV_intel
Moderator
3,051 Views

Hi,


Do you see the same error message when you'd tried with gcc 9.3.0?


Add your latest gcc version path to the basrc file ($PATH) and see if it helps. Also include --std=c++17 flag when you compile.


Let me know if it helps.



Regards,

Rahul


0 Kudos
breyerml
Novice
3,043 Views

Hi,

my current $PATH environment variable looks like (: replaced by \n for a better readability):

 

/home/u49380/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/gcc-7.4.0/gcc-9.3.0-c54ppf7fympcyyctgusm26dwc3xisvh5/bin
/home/u49380/spack/bin
/glob/development-tools/versions/ispc/ispc-v1.13.0-linux/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/itac/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/itac/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/inspector/2021.1-beta09/bin64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/intelpython/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/dev-utilities/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/vpl/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/clck/2021.1-beta09/bin/intel64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/openvkl/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/vtune/2021.1-beta09/bin64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/lib/oclfpga/llvm/aocl-bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/lib/oclfpga/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/bin/intel64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/ioc/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/dpcpp-ct/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/advisor/2021.1-beta09/bin64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/mkl/2021.1-beta09/bin/intel64
/glob/development-tools/versions/oneapi/beta09/inteloneapi/embree/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/ospray/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/oidn/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/libfabric/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/debugger/10.0-beta09/gdb/intel64/bin
/opt/intel/inteloneapi/intelpython/latest/bin
/glob/development-tools/versions/oneapi/beta09/inteloneapi/intelpython/latest/condabin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/home/u49380/.local/bin
/home/u49380/bin
/bin

 

GCC 9.3.0 is my first entry in $PATH so that shouldn't be a problem.

As of -std=c++17: I'm using CMake 

target_compile_features(${SYCL_LSH_LIBRARY_NAME} PUBLIC cxx_std_17)

The output of make VERBOSE=1 is:

/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/bin/dpcpp  -DFMT_LOCALE -DSYCL_LSH_DEBUG -DSYCL_LSH_TARGET=0 -DSYCL_LSH_TIMER=2 -Dsycl_lsh_EXPORTS -I/home/u49380/distributed_gpu_lsh_using_sycl/include -isystem /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/include -isystem /home/u49380/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/gcc-7.4.0/fmt-7.0.3-vdd4urgcp5n2gl7jrbhpi6yy4jrlassu/include  -O3 -DNDEBUG -fPIC   -Wno-format-security --gcc-toolchain=/home/u49380/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/gcc-7.4.0/gcc-9.3.0-c54ppf7fympcyyctgusm26dwc3xisvh5 -std=gnu++1z -o CMakeFiles/sycl_lsh.dir/src/sycl_lsh/argv_parser.cpp.o -c /home/u49380/distributed_gpu_lsh_using_sycl/src/sycl_lsh/argv_parser.cpp

(It uses GCC 9.3.0 but strangely it doesn't set -std=c++17 but -std=gnu++1z)

The linker command is:

/usr/bin/cmake -E cmake_link_script CMakeFiles/prog.dir/link.txt --verbose=1
/glob/development-tools/versions/oneapi/beta09/inteloneapi/compiler/2021.1-beta09/linux/bin/dpcpp  -O3 -DNDEBUG   CMakeFiles/prog.dir/src/main.cpp.o  -o prog -Wl,-rpath,/home/u49380/distributed_gpu_lsh_using_sycl/build libsycl_lsh.so -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/lib/release -Xlinker -rpath -Xlinker /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/lib -Wl,-z,now -Wl,-z,relro -Xlinker --enable-new-dtags /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/lib/libmpicxx.so /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/lib/libmpifort.so /glob/development-tools/versions/oneapi/beta09/inteloneapi/mpi/2021.1-beta09/lib/release/libmpi.so /usr/lib/x86_64-linux-gnu/librt.so -lpthread /usr/lib/x86_64-linux-gnu/libdl.so /home/u49380/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/gcc-7.4.0/fmt-7.0.3-vdd4urgcp5n2gl7jrbhpi6yy4jrlassu/lib/libfmt.a -fsycl -shared-libgcc -lstdc++fs

Which fails with:

/home/u49380/tmp/main-b165c9.o: In function `custom_main(int, char**)':
main.cpp:(.text+0x3eb): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
main.cpp:(.text+0x419): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
main.cpp:(.text+0x436): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
main.cpp:(.text+0x476): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
main.cpp:(.text+0x2191): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
main.cpp:(.text+0x2614): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
main.cpp:(.text+0x2662): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
/home/u49380/tmp/main-b165c9.o: In function `std::filesystem::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::filesystem::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::filesystem::__cxx11::path::format)':
main.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x7c): undefined reference to `std::filesystem::__cxx11::path::_List::_List()'
main.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x84): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
main.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0xab): undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const'
dpcpp: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/prog.dir/build.make:102: recipe for target 'prog' failed
make[2]: *** [prog] Error 1
make[2]: Leaving directory '/home/u49380/distributed_gpu_lsh_using_sycl/build'
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/prog.dir/all' failed
make[1]: *** [CMakeFiles/prog.dir/all] Error 2
make[1]: Leaving directory '/home/u49380/distributed_gpu_lsh_using_sycl/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
0 Kudos
RahulV_intel
Moderator
3,027 Views

Hi,


-std=gnu++1z is just an alias name for C++17.


Since the program fails during linking, my guess is that it's still picking up the older -lstdc++fs library.


0 Kudos
RahulV_intel
Moderator
3,004 Views

Hi,


Any updates on this?


Thanks,

Rahul


0 Kudos
RahulV_intel
Moderator
2,975 Views

Hi,


Since your actual question is resolved, I will go ahead and close this thread from my end. Feel free to post a new question if you still face any issue.



Thanks,

Rahul


0 Kudos
Reply