optixu/optixpp_namespace.h double including

Hi all.

simple file: test.cu

#include <optixu/optixpp_namespace.h>
#include <optixu/optixpp_namespace.h>

compilation command

/usr/local/cuda-10.1/bin/nvcc -isystem /usr/local/optix-6.0.0/include test.cu

cause errors:

/usr/local/optix-6.0.0/include/optix_gl_interop.h(115): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(204): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(204): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(236): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(236): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(269): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(269): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(305): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(305): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(338): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(338): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(372): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(372): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_gl_interop.h(405): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_gl_interop.h(405): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(71): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(71): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(107): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(107): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(141): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(141): error: expected a ";"

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(177): error: variable "RTAPI" has already been defined

/usr/local/optix-6.0.0/include/optix_cuda_interop.h(177): error: expected a ";"

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(127): error: identifier "RTobject" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(229): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(238): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(241): error: identifier "rtContextGetErrorString" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(290): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(295): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(595): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(597): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(610): error: identifier "RTvariable" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(613): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(616): error: identifier "RTvariable" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(618): error: identifier "RTvariable" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(619): error: identifier "RTvariable" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(660): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(696): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(699): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(702): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(702): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(705): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(705): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(708): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(708): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(708): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(711): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(711): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(711): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(715): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(715): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(718): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(718): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(718): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(721): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(721): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(724): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(724): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(724): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(732): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(735): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(735): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(738): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(738): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(738): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(839): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(854): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(874): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(874): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(877): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(877): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(889): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(891): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(907): error: identifier "RTtimeoutcallback" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(911): error: identifier "RTusagereportcallback" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(951): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(953): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(953): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(955): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(955): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(955): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(960): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(960): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(975): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(977): error: identifier "RTsize" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(993): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(995): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(998): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(999): error: identifier "RTcontext" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1029): error: identifier "RTprogram" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1031): error: identifier "RTprogram" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1033): error: identifier "RTprogram" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1034): error: identifier "RTprogram" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1095): error: identifier "RTgroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1098): error: identifier "RTgroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1100): error: identifier "RTgroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1101): error: identifier "RTgroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1163): error: identifier "RTgeometrygroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1166): error: identifier "RTgeometrygroup" is undefined

/usr/local/optix-6.0.0/include/optixu/optixpp_namespace.h(1168): error: identifier "RTgeometrygroup" is undefined

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_00003fa0_00000000-8_test.cpp1.ii".
Compilation terminated.

I tried optix-5.1.1 and nvcc from cuda 9.2 with same result.
I did not find anything strange in optix headers (all header guards on their place), so I am not sure that it is not bug on nvcc.

Also

#include <optix.h>
#include <optixu/optixpp_namespace.h>

cause same errors, but

#include <optix.h>
#include <optix.h>

compiles fine

Both files have include guards to prevent multiple include, right? Maybe it is an nvcc bug, we’ll look into it. Thanks for the note.


David.

Yep. It was the first thing I checked.

optixpp_namespace.h implements the C++ wrapper over the OptiX C API which should only be included inside host code.
It’s not meant to be included in *.cu files implementing the OptiX device side programs of your ray tracing.

Here’s an example for host side and device side includes for OptiX:
https://github.com/nvpro-samples/optix_advanced_samples/blob/master/src/optixIntroduction/optixIntro_01/src/Application.cpp#L33
https://github.com/nvpro-samples/optix_advanced_samples/blob/master/src/optixIntroduction/optixIntro_01/shaders/raygeneration.cu#L31

Thank you, Detlef.

I see that it is nothing relative to cuda code.

But this behavior still very strange.