Including `string_view`

Hi all,

I have a test file which just consists of #include <string_view>. This leads to the error cannot open source file "string_view". About this, the reference guide (HPC Compiler Reference Manual Version 23.3 for ARM, OpenPower, x86) states that NVC++ does not include a C++ standard library and mentions stdt::string_view explicitly among the libraries which need to be provided externally.

I’m using the HPC SDK 23.3. Within its installation directory, I found string_view include files, but providing them with -I just gives the multitude of error messages in the file in
test_stringview.out (21.8 KB). There are various syntax errors which are due to unexpanded macros.

Similar things happen when I use string_view includes from GCC installations. Also, the -std=gnu++17 option does not change the result.

What is the usual way to include std::string_view and the other libraries? I guess that various other include paths need to be set.

Best regards,

Hi Christian,

The header file directory you’re pointing at is for the CUDA C++ STL and not intended for the host.

What you need is a GNU STL installation that supports C++ 17. Something like 9.3 or newer.

What g++ version do you have installed?

By default, nvc++ will be configured to use the default GNU STL installed on the system. You can change which version nvc++ uses via the “–gcc-toolchain=/path/to/gnu/install” flag.

Alternatively, you can update the NVHPC configuration file “localrc” via the command:

makelocalrc -d . -x -gcc=/path/to/gnu/bin/gcc -gpp=/path/to/gnu/bin/gnu/bin/g++ -g77=/path/to/gnu/bin/gfortran

then set the environment variable “NVLOCALRC=/path/to/localrc” to the new config file. You can rename the file if needed.

Hope this helps,

Hi Mat,

thanks for your help. Using the --gcc-toolchain option, I can compile the code.

Best regards,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.