NVHPC 25.1: nvc++ cannot find <iostream>

I am trying to use NVIDIA HPC SDK 25.1 with nvc++ to compile a simple C++ program, but it fails to find . With g++ or nvcc, the same code works fine.

Environment

  • OS: CentOS Linux 8

  • GCC version: 8.5.0 (Red Hat 8.5.0-3)

  • NVHPC version: 25.1

  • Install path: /public/software/compiler/nvhpc_sdk

test.cpp:

include

int main() {

std::cout << "Hello from nvc++" << std::endl;

return 0;

}

nvcc test.cpp -o test # works, runs and prints “Hello from nvc++”

nvc++ test.cpp -o test # fails

“test.cpp”, line 1: catastrophic error: cannot open source file “iostream”
1 catastrophic error detected in the compilation of “test.cpp”.

Compilation terminated.

[root@admin nccl-tests-2.17.1]# ls /usr/include/c++/8/iostream
/usr/include/c++/8/iostream

Running nvc++ -### test.cpp shows many --sys_include paths, but not /usr/include/c++/8.

Why does nvc++ fail to detect the system libstdc++ headers by default on CentOS 8?

Do I need to run makelocalrc or some additional configuration to point it to GCC 8.5.0?

Is it recommended to avoid setting CPATH/CPLUS_INCLUDE_PATH in the modulefile?

Thanks in advance for your help!

Hi lth112347 and welcome!

This does seem like a configuration issue. Did the system get updated with the new OS since you’ve used it before or is this a new system?

A bit ago, we switched how the local config files (localrc) are generated in that they now get created for each user, for each system, and each release, the first time the compilers are run.

These files will be found in you home directory under “~/.config/NVIDIA/nvhpc/25.1/localrc.<hostname>”. So if the system’s OS got updated, then the previous localrc file could still be there and you can try deleting it, so it gets regenerated the next time you run the compiler.

We can try generating one via makelocalrc and then set the environment variable “NVLOCALRC=” to point to it, if the above doesn’t clear it.

[root@admin nccl-tests-2.17.1]

Are you running as root?

-Mat

As another data point, I have seen this kind of issue when an Ubuntu node was added to a cluster that was otherwise all Rocky. Libraries and possibly other files are in different locations, and you need to configure for the new setup.

Thanks! This is a brand-new system, and the NVIDIA HPC SDK (nvhpc 25.1) was freshly installed. The error appears even after regenerating the localrc file as described above.

I already executed:

/public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin/makelocalrc \

-x /public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin

and then set the environment variable:

[root@admin ~]# export NVLOCALRC=/public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin/localrc

[root@admin 4090]# module load compiler/nvhpc/25.1

After that, when I try to compile a simple C++ file:

[root@admin 4090]# nvc++ -o test test.cpp

I still get the following error:

“test.cpp”, line 1: catastrophic error: cannot open source file “iostream”

include
^

1 catastrophic error detected in the compilation of “test.cpp”.

This is the content of the localrc file:

[root@admin 4090]# less /public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin/localrc
set LFC=-lgfortran;
set LDSO=/lib64/ld-linux-x86-64.so.2;
set GCCDIR=;
set G77DIR=;
set OEM_INFO=64-bit target on x86-64 Linux $INFOTPVAL;
set GNUATOMIC=;
set GCCINC=;
set GPPDIR=;
set NUMALIBNAME=-lnuma;
set LOCALRC=YES;
set EXTENSION=extension=;
set LC=-lgcc -lc -lgcc_s;
set DEFCUDAVERSION=12.6;
set DEFSTDPARCOMPUTECAP=;

GLIBC version 2.28

GCC version 8.5.0

set GCCVERSION=80500;
set LIBNCURSES=YES;
export PGI=$COMPBASE;

makelocalrc executed by root 2025年 09月 11日 星期四 10:08:13 CST

/public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin/localrc (END)

Interestingly, if I use nvcc, I can compile and run the same code successfully.

I also tried reinstalling the SDK, but the problem remains the same.

Could you please advise me on the next steps to resolve this issue?

Thank you very much for your support and for the great work you are doing with the HPC SDK.

I tried installing the same tarball (single install) on a new Ubuntu 24.04.3 machine. On this system, nvc++ is able to find the iostream header correctly.

In /opt/nvidia/hpc_sdk/Linux_x86_64/25.1/compilers/bin I found the localrc file, whose contents are:

set LDSO=/lib64/ld-linux-x86-64.so.2;
set GCCDIR=/usr/lib/gcc/x86_64-linux-gnu/13/;
set OEM_INFO=64-bit target on x86-64 Linux $INFOTPVAL;
set GNUATOMIC=-latomic;
set GCCINC=/usr/lib/gcc/x86_64-linux-gnu/13/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include;
set GPPDIR=/usr/include/c++/13 /usr/include/x86_64-linux-gnu/c++/13 /usr/include/c++/13/backward /usr/lib/gcc/x86_64-linux-gnu/13/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include;
set NUMALIBNAME=;
set LOCALRC=YES;
set EXTENSION=_extension_=;
set LC=-lgcc -lc $if(-Bstatic,-lgcc_eh, -lgcc_s);
set DEFSTDOBJDIR=/usr/lib/x86_64-linux-gnu;
set DEFCUDAVERSION=12.6;
set DEFSTDPARCOMPUTECAP=;
# GLIBC version 2.39
# GCC version 13.3.0
set GCCVERSION=130300;
export PGI=$COMPBASE;
# makelocalrc executed by root 2025年 09月 11日 星期四 16:06:24 CST

Compared with the localrc I had on my previous machine, this one includes more variables. I’m wondering if I could simply modify the old machine’s localrc by hand to solve the problem.

Odd, all the GNU variable with the directory information is coming up blank. The script queries gcc and g++ to get this information. So I suspect that there’s something off with your gcc install, possibly you’re missing the GNU development package?

What’s the output from the command: “gcc -E -Wp,-v -x c foo.c”?

I’m wondering if I could simply modify the old machine’s localrc by hand to solve the problem.

You can, though if there is a missing install for GNU, then you’ll likely have other issues.

Thanks!

This it the comtent of the foo.c:
# include <stdio.h>

int main(void) {
printf(“Hello, world!\n”);
return 0;
}
I ran the command and get the following result:
foo.txt (15.2 KB)
I tried yum reinstall gcc and then reinstalled nvhpc, but I found the result was the same.
Then I tried this command:

/public/software/compiler/nvhpc_sdk_test/Linux_x86_64/25.1/compilers/bin/makelocalrc \
  -x /public/software/compiler/nvhpc_sdk_test/Linux_x86_64/25.1/compilers/bin \
  -gcc gcc -gpp g++

However, the contents of the localrc file didn’t change at all, although the program exited normally.

I also tried using other versions of gcc and g++, but the effect was the same.

May I ask, apart from manually modifying localrc, is there any other method available?

I noticed this command. Is this a site-local setup of some kind? I just add the modulefiles directory and I see

---------------------------- /opt/nvidia/hpc_sdk/modulefiles -----------------------------
nvhpc-byo-compiler/25.7 nvhpc-hpcx-cuda12/25.7 nvhpc-nompi/25.7
nvhpc-hpcx-2.20-cuda12/25.7 nvhpc-hpcx/25.7 nvhpc/25.7

Oh, and doing this as root is not a good idea (to echo Mat’s comment)

Until we know what the problem is, I don’t have another solution.

When you ran the command “gcc -E -Wp,-v -x c foo.c”, what was printed to stderr?

I can’t quite tell if nothing printed, or you just omitted posting it.

It should have shown the search path for the include files, something like:

% gcc -E -Wp,-v -x c foo.c > foo1.txt
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/11/include
 /usr/local/include
 /usr/include
End of search list.
% gcc -E -Wp,-v foo.cpp > foo1.txt
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11
 /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/x86_64-redhat-linux
 /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/backward
 /usr/lib/gcc/x86_64-redhat-linux/11/include
 /usr/local/include
 /usr/include
End of search list.

Also, I noticed in the output you provided, several non-printable characters:

# 1 "foo.c"
# 1 "<built-in>"
# 1 "<命令行>"
# 31 "<命令行>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<命令行>" 2

These correspond to “<command-line>”, which just indicates that the compile was issued from the command line, so may not matter, but I’m wondering if the locale might have something to do with it.

What’s the output from the command “locale”?

Thanks — here are the exact outputs you asked for.
gcc -E -Wp,-v -x c foo.c (stderr):
c_stderr.txt (1.4 KB)
gcc -E -Wp,-v foo.cpp (stderr):
cpp_stderr.txt (1.6 KB)
locale:
locale.txt (330 Bytes)
Really appreciate your guidance — this helps me a lot!

You’re locale is “en_US.UTF-8” so that’s fine, I just can’t explain the odd characters (I guessed that the may be Chinese characters), but it may have just been a copy and paste thing.

Now in the output you are getting some extra include directories which aren’t default, presumably you have these added to you’re environments CPATH, C_INCLUDE_PATH, and/or CPLUS_INCLUDE_PATH variables. Though when I try doing the same, the localrc file is still correct.

I’m out of ideas so let me ask some other folks.

They would like to see the debug output from makelocalrc. Can you run the following commands and post the full output?

bash -x makelocalrc -n -gcc /usr/bin/gcc -gpp /usr/bin/g++
bash -x makelocalrc -n

Thank you very much for your guidance!
My server was compromised earlier, so I reinstalled the system. After that I ran the command you suggested and here are the outputs: output1.txt (57.8 KB) and output2.txt (28.2 KB).

I also tried running the command makelocalrc -x /public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin -gcc gcc -gpp g++again, and I noticed that the file
/public/software/compiler/nvhpc_sdk/Linux_x86_64/25.1/compilers/bin/localrc
has indeed been updated. The contents now look like this:

set LFC=-lgfortran;
set LDSO=/lib64/ld-linux-x86-64.so.2;
set GCCDIR=/usr/lib/gcc/x86_64-redhat-linux/8/;
set G77DIR=/usr/lib/gcc/x86_64-redhat-linux/8/;
set OEM_INFO=64-bit target on x86-64 Linux $INFOTPVAL;
set GNUATOMIC=;
set GCCINC=/usr/lib/gcc/x86_64-redhat-linux/8/include /usr/local/include /usr/include;
set GPPDIR=/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward /usr/lib/gcc/x86_64-redhat-linux/8/include /usr/local/include /usr/include;
set NUMALIBNAME=-lnuma;
set LOCALRC=YES;
set EXTENSION=__extension__=;
set LC=-lgcc -lc $if(-Bstatic,-lgcc_eh, -lgcc_s);
set DEFCUDAVERSION=12.6;
set DEFSTDPARCOMPUTECAP=;
# GLIBC version 2.28
# GCC version 8.5.0
set GCCVERSION=80500;
set LIBNCURSES=YES;
export PGI=$COMPBASE;
# makelocalrc executed by root Thu Sep 18 21:48:08 EDT 2025

This time it looks normal, and I was able to successfully compile a simple “Hello World” with nvc++.
Thanks again for your help! I really appreciate the time you spent on this.

Wishing the NVIDIA HPC SDK project continued success — and thank you once more for your kind support!

1 Like

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