error C1189: #error : "optixu_math_namespace.h needs NOMINMAX defined on windows."

I met the problem when compiling the optix project, If I want to solve the problem what should I do? Where and how should I define the NOMINMAX? My Optix version is 3.0.1

I suggest you to include OptiX headers in the way they’re supposed to be used (that will make things way easier). If you’re trying to use rtu* APIs just include <optix_world.h> as in the traversal sample shipped with the SDK

What does “in the way they’re supposed to be used” mean? I know optix.h header file is used for C API, and optix_world.h is used for C API and C++ API, I have read the program guide manual chapter 5 building with optix, but I still can solve the problem

you have to undefine the windows.h min and max macros using NOMINMAX.

Right Click on your project in Visual Studios, select configuration properties->C/C+±>Preprocessor->Preprocessor Definitions


Sorry max I thought you were including optixu_math_namespace.h directly. If you’re using it by first defining windows.h then mdkoa1’s suggestion is correct (thanks md!)

Thank you, marknv and mdkoa1, you really help me a lot.

What does the word “directly” imply? Is there a indirect way to include optixu_math_namespace.h? Although I have solved the problem as mdkoal said, I want to know something .

Some headers are just not meant to be included directly into C/C++ programs since they might require other headers before or macros defined.

You can include optixu_math_namespace.h in your source files “directly” (e.g. not through including another file).

And the error message about NOMINMAX generally needs to be solved not by including a particular header file from optix, but by defining it as a compiler preprosessor definition like mdkoa1 describes.

Including a header directly doesn’t always work but that’s true for optixu_math_namespace (I didn’t verify it for that header).