Can not found stdlib.h with pgc++ 18.4

I run

/content/pgi/linux86-64/18.4/bin/pgc++  -D_OACC_ENABLE_ -I/content/HaskellFAI/example/example-blas/include -I/usr/local/include  -O3  -acc  --c++11 --gnu_extensions -o CMakeFiles/example-blas-test.dir/test/vector_opt_test.cc.o -c /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc -v

but I got

Export PGI=/content/pgi

/content/pgi/linux86-64/18.4/bin/pggpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__extension__= -D__amd_64__amd64__ -D__k8 -D__k8__ -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I/content/HaskellFAI/example/example-blas/include -I/usr/local/include -I/usr/local/cuda-8.0/include -I- -I/content/pgi/linux86-64/18.4/include-gcc70 -I/content/pgi/linux86-64/18.4/include -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include -D_ACCEL=201003 -D_OPENACC=201711 -D__CUDA_API_VERSION=8000 -DPGI_TESLA_TARGET -D_OACC_ENABLE_ --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=70200 -D__pgnu_vsn=70200 --accel --preinclude openacc_predef.h --c++11 --gnu_extensions -q -o /tmp/pgc++xjnfwstlGfE.il /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc
"/usr/include/c++/7/cstdlib", line 75: catastrophic error: cannot open source
          file "stdlib.h"
  #include_next <stdlib.h>
                          ^

1 catastrophic error detected in the compilation of "/content/HaskellFAI/example/example-blas/test/vector_opt_test.cc".
Compilation terminated.
pgc++-Fatal-cpp1 completed with exit code 4

However, after I appended -I/usr/include/c++/7

!/content/pgi/linux86-64/18.4/bin/pgc++  -D_OACC_ENABLE_ -I/content/HaskellFAI/example/example-blas/include -I/usr/local/include  -O3  -acc  --c++11 --gnu_extensions -o CMakeFiles/example-blas-test.dir/test/vector_opt_test.cc.o -c /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc -v -I/usr/include/c++/7

And got

Export PGI=/content/pgi

/content/pgi/linux86-64/18.4/bin/pggpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__extension__= -D__amd_64__amd64__ -D__k8 -D__k8__ -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I/content/HaskellFAI/example/example-blas/include -I/usr/local/include -I/usr/include/c++/7 -I/usr/local/cuda-8.0/include -I- -I/content/pgi/linux86-64/18.4/include-gcc70 -I/content/pgi/linux86-64/18.4/include -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include -D_ACCEL=201003 -D_OPENACC=201711 -D__CUDA_API_VERSION=8000 -DPGI_TESLA_TARGET -D_OACC_ENABLE_ --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=70200 -D__pgnu_vsn=70200 --accel --preinclude openacc_predef.h --c++11 --gnu_extensions -q -o /tmp/pgc++jsnB3cjvOgu.il /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc
"/content/HaskellFAI/example/example-blas/test/test_prelude.h", line 29:
          warning: last line of file ends without a newline
  #endif // ! _TEST_PRELUDE_H_
                              ^

"/content/HaskellFAI/example/example-blas/test/vector_opt_test.cc", line 603:
          warning: last line of file ends without a newline
  #endif // DO_VECTOR_SCALE == 1
                                ^


/content/pgi/linux86-64/18.4/bin/pggpp2 /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc -opt 3 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -vect 56 -y 34 16 -x 34 0x8 -x 32 47185920 -y 19 8 -y 35 0 -x 42 0x30 -x 39 0x40 -x 39 0x80 -x 59 4 -x 129 2 -tp haswell -x 120 0x1000 -astype 0 -x 121 1 -fn /content/HaskellFAI/example/example-blas/test/vector_opt_test.cc -il /tmp/pgc++jsnB3cjvOgu.il -x 117 0x600 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=70200 -autoinl 10 -x 168 400 -x 174 128000 -x 14 0x200000 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -accel tesla -accel host -x 186 0x80000 -x 180 0x4000400 -x 163 0x1 -cudaver 8000 -x 176 0x100 -cudacap 35 -cudacap 50 -cudacap 60 -x 121 0xc00 -x 194 0x40000 -x 186 0x80 -x 189 0x8000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -cudaroot /usr/local/cuda-8.0 -x 9 1 -x 72 0x1 -x 136 0x11 -quad -x 119 0x10000000 -x 129 0x40000000 -x 164 0x1000 -gnuvsn 70200 -x 69 0x200 -cmdline '+pgc++ /tmp/pgc++jsnB3cjvOgu.il -D_OACC_ENABLE_ -I/content/HaskellFAI/example/example-blas/include -I/usr/local/include -O3 -Mvect=sse -Mcache_align -Mpre -acc --c++11 --gnu_extensions -o CMakeFiles/example-blas-test.dir/test/vector_opt_test.cc.o -c -v -I/usr/include/c++/7' -asm /tmp/pgc++rsnZY5zGwJ-.s
PGCC/x86 Linux 18.4-0: compilation successful

/usr/bin/as /tmp/pgc++rsnZY5zGwJ-.s -I/content/HaskellFAI/example/example-blas/include/ -I/usr/local/include/ -I/usr/include/c++/7/ -I/usr/local/cuda-8.0/include/ -o CMakeFiles/example-blas-test.dir/test/vector_opt_test.cc.o
Action(ReadTIFile(./vector_opt_test.ti))
Unlinking /tmp/pgc++jsnB3cjvOgu.il
Unlinking /tmp/pgc++rsnZY5zGwJ-.s
Unlinking /tmp/pgc++zsnljO1zvw2.ll

I have no ideas about why I got the bug, and why it work after append “-I/usr/include/c++/7”.

Hi Qinka,

I have no ideas about why I got the bug, and why it work after append “-I/usr/include/c++/7”

This is very odd especially given that the compiler is implicitly adding “-I/usr/include/c++/7” already (you can see it in the verbose output from the failing case), and that “stdlib.h” is a C header file so wouldn’t be in this directory.

The only thing I can think of is that it’s an ordering issue where by putting “-I/usr/include/c++/7” before “-I/content/pgi/linux86-64/18.4/include-gcc70 -I/content/pgi/linux86-64/18.4/include” you’re picking up the PGI supplied “stdlib.h”? But this would only be an issue if your system include directories were incomplete and missing this standard header file.

Does “stdlib.h” exist in “/usr/include”?

-Mat