Missing stdafx.h after configuring with cmake of sdk

I generated the solution Optix-Samples with the cmake.
when compiling the solution it gives the error that stdafx.h is missing.
what to do?

That’s a Microsoft Visual Studio related question and has nothing to do with the OptiX SDK.

Please do some research about what stdafx.h does or did at all and which MSVS settings generate and name it.



Other than that, please always list the following system configuration information when asking about an issue related to OptiX:
OS version, installed GPU(s), display driver version number, OptiX version (major.minor.micro), CUDA toolkit version (major.minor), host compiler version and edition, CMake version.

That would at least explain what OptiX-Samples you tried to build with what MSVS version und CUDA toolkit.
It still wouldn’t explain why there is any error about a stdafx.h for the precompiled headers because that name does not appear in any OptiX SDK version’s code.

I managed to pass this problem, and compilation succeeded however a ptx is not generated.
the optix_hello looks for the ptx and fails when it doesnt find it.
I added in configuration - cuda/c++/nvcc compilation type - generate ptx
and gave a path to build x64.
what should I do?
optix 5.1.0
cuda 7
sm 20
windows 10

the optix_hello looks for the ptx and fails when it doesnt find it.

Again, if you ask a question on any developer forum about errors, you should at least spend enough time to copy-and-paste the exact error message into your question.
It’s unclear why something is not found again and I can think of multiple reasons.

I added in configuration - cuda/c++/nvcc compilation type - generate ptx

There is no need to change any code inside the CMakeLists.txt files or the MSVS solution settings after it was built.

The optixHello program inside the OptiX SDK 5.1.0 uses only the draw_color.cu file.
The default settings for the OptiX SDK 5.1.0 examples is to translate the *.cu files to *.ptx files at runtime using the NVRTC (NVIDIA CUDA Runtime Compiler) instead of the NVCC (NVIDIA CUDA Compiler) at build time.

Either the NVRTC is not working (most likely because CUDA 7.0 is too old), it’s not finding the *.cu file, or you compiled them at build time and the *.ptx files are not found, because you didn’t run the programs where they have been originally built.

CUDA 7.0 is too old to be used with NVRTC. That contains this functionality as beta only and the code was not optimally translated before CUDA 8.0 when using NVRTC.

Inside the CMake GUI there is a variable named CUDA_NVRTC_ENABLED which you can uncheck to let the *.ptx source be generated with NVCC at compile time, if NVRTC is not working on your development machine, or you don’t want to use that.

There should be a file named optixHello_generated_draw_color.cu.ptx produced when using the NVCC compiler, which your self-built executable should find when run from its build folder.

If you copy stuff to different locations, you would need to set two environment variables to find the *.ptx and data.

Please, again, seriously(!), upgrade your development environment software to something more modern:
For OptiX 5.1.0:MSVS 2017 and CUDA 9.0,
For OptiX 6.5.0:MSVS 2017 or 2019 and CUDA 10.1.
For OptiX 7.x: MSVS 2017 or 2019 and CUDA 10.x or CUDA 11.x.