How can I generate a .ptx file for rtProgramCreateFromPTXFile

I begin to play Optix recently, but there is a problem making me disheartened,it’s about a function.
RTresult rtProgramCreateFromPTXFile(RTcontext context,const char* filename,const char* program_name,RTprogram* program)
In this function,there is a argument “filename”,it saves PTX code related to rtProgram.

At the moment,I create an Optix project with visual studio by copying examples from Optix SDK,It works well. Now but I want to create my own project,which means I will write a .cu file , but how can I get PTX  file from .cu file? I have tried to create a PTX file like this:
Open a project created by VS2010, select the .cu file file,for example, "" . right click ,and select compile option, it ends without error,but the PTX file didn't appear, I don't know why.

So I hope to know the right procedure to create a PTX file for a Program.Thank you

The “Right Click and compile” option does not work because you did not set the appropriate CUDA targets.

Follow the steps as described. I am assuming you have created a new VS2010 empty project and your libraries and header files directories have already been set properly:

  1. Right click on your visual studio solution and select “Build Customizations”. If you have installed CUDA, you will see CUDA 4.2(.targets, .props) or CUDA 5.0(.targets, .props). Select by ticking the appropriate box on the CUDA version you wished to use.

  2. Right Click on your solution again. Then select Configuration Properties->CUDA C/C++.
    Set NVCC Compilation Type to “Generate .ptx file (-ptx)”.
    Set Compiler Output to the folder or filename that you prefer but with a .ptx extension. This will be the location where the ptx file will be generated.
    Set Additional Include Directories to your Optix header file directories. For example:
    C:\Program Files\NVIDIA Corporation\OptiX SDK 3.0.0\include

  3. If you are using your SDK example source code, you have to change the location that your ptx files are read. Because in some of the SDK examples, the application reads the ptx file from the default SDK folder.

Thank you very much,mdkoal, what you said is really helpful.I have generated the .ptx file as you told.

We have an alternative way for generating projects with OptiX forthcoming: a VS2012 wizard (take a look at SIGGRAPH2013 tech talks). It could help for a quick prototype and/or if you’re having troubles setting things by yourself.

where is that wizard? i’ve been trying to find it to build new optix apps but don’t know how to use it

It will be shipped within the next OptiX release (and that should happen soon)