How would you generally compile and run a program which has optix without make or cmake?

we generally use g++ src/* for compiling c++ source and $nvcc src/* for compiling cuda. I am starting out nvidia optix so I need some help regarding this.

A small demo code would help. The samples and the advanced samples have got ccmake so I cannot easily follow how to compile.

I’m not using Linux so I can’t give a definitive command line for gcc.

Compiling OptiX shader program CUDA device code from *.cu to *.ptx can be easily done with a standalone command line. Mind that you don’t compile to CUDA obj or cubin files, you only need to generate *.ptx source via the --ptx switch and -o .ptx output

nvcc --help dumps all possible command line options.

If you look into optix_advanced_samples/src/CMake/FindCUDA/run_nvcc.cmake you can find the NVCC command line variables constructed there.

Search for this custom build step:

# Generate the code
cuda_execute_process(
  "Generating ${generated_file}"
  COMMAND "${CUDA_NVCC_EXECUTABLE}"
  "${source_file}"
  ${format_flag} -o "${generated_file}"
  ${CCBIN}
  ${nvcc_flags}
  ${nvcc_host_compiler_flags}
  ${CUDA_NVCC_FLAGS}
  -DNVCC
  ${CUDA_NVCC_INCLUDE_ARGS}
  ${get_error}
  )

# Add this next line:
message("Command line: ${CUDA_NVCC_EXECUTABLE} ${source_file} ${format_flag} -o ${generated_file} ${CCBIN} ${nvcc_flags} ${nvcc_host_compiler_flags} ${CUDA_NVCC_FLAGS} -DNVCC ${CUDA_NVCC_INCLUDE_ARGS}")

If you add that message line I listed in the code excerpt above, then it will print the exact command line used for each *.cu to *.ptx translation in the examples during build time (without necessary quotation marks around file names with spaces, but you’ll get the idea.)

This post contains a list of command line options required to compile OptiX programs with NVRTC at runtime (without a host compiler!).
The options are the same for NVCC, just that NVCC supports more options than NVRTC. Read the code comments there.
https://devtalk.nvidia.com/default/topic/1047572/optix/optix-compile-error-in-ptxstring/post/5316118/#5316118