Optix in cmake

When i cmake my optix project, i get this error:
but if i include the optix_stubs.h,i get another error:

why this error occurs?

The error occurs because you seem to have “warnings as errors” (-Werror) enabled in your project and the compiler complains about that the OptixFunctionTable fields do not have explicit initializers for all fields.

While the code OptixFunctionTable empty = { 0 }; is only specifying an explicit initializer for the first field in that struct, all other fields will be set to zero as well by that code, so that is not an error and the warning is benign.

If you search the web for that error, that seems to be something older GCC versions complained about, which should have been fixed in newer versions.

You could either

  • try newer GCC versions or
  • explicitly disable that warning only or
  • switch off the warnings-as-error setting or
  • change the code to something your specific compiler doesn’t complain about.

Maybe try this:

OptixFunctionTable empty = {};

or this:

OptixFunctionTable empty;
memset(&empty, 0, sizeof(OptixFunctionTable));