LinkerError with ptxpath->sutilSamplesPtxDir

Hello,

right now im trying to combine optix raycasting with openGl Rendering.
For this case i found an fitting example.
I need to create an ptx file from my cuda files just like its done in the tutorial of OptiX,
so somehow like this:

std::string box_ptx( ptxpath( “tutorial”, “box.cu” ) );
Program box_bounds = m_context->createProgramFromPTXFile(box_ptx, “box_bounds”);
Program box_intersect = m_context->createProgramFromPTXFile(box_ptx, “box_intersect”);

but in my application i get an Linkererror for ptxpath, or if go on step further and take the given implementation of ptxpath:

const char* const SampleScene::ptxpath( const std::string& target, const std::string& base )
{
static std::string path;
path = std::string(sutilSamplesPtxDir()) + “/” + target + “generated” + base + “.ptx”;
return path.c_str();
}

i get the linkererror for sutilSamplesPtxDir, eventhough there is an sutil.c with the definition of sutilSamplesPtxDir.

sutilSamplesPtxDir is declared as an dllimported function. So my question now, which dll or lib do i have to link, so the linker knows where to get the defintion?

im using VS2013.

if you need further information just ask. Thank you.

Are you working inside the OptiX SDK examples folder, respectively a copy of that and did you built the sutil library project inside the examples’ solution?

The OptiX SDK examples link against the sutil.lib at compile time and load the sutil.dll at runtime.

You would first need to build the sutil project inside the OptiX examples solution you generated with the topmost CMakeLists.txt you can find. Read the comments in that, it explains how to add own examples into the SDK’s folder structure.

Or are you working in a separate project and want to be independent from the OptiX SDK folder hierarchy?
In the latter case you could simply replace the sutilSampleDirs() call with something which returns the proper PTX filename you want to use.

In my own projects I normally place all renderer core PTX files into a sub-folder next to the executable and can then simply load them from that relative(!) folder location on any system. No hardcoded absolute file locations involved then.

Looks something like this:

std::map<std::string, optix::Program> m_mapOfPrograms;
...
m_mapOfPrograms["boundingbox"] = m_context->createProgramFromPTXFile("./ptx_my_app_name/boundingbox.ptx", "boundingbox");

Yes Im working outside the SDK folder hierachy.
Ok thanks for that I’ll try this for my application.

Thank you.

Ok, i tried it for my application, but i think something is wrong with my folder structure, because the checkError tells me “RT_ERROR_FILE_NOT_FOUND”.

My Code now looks like this:

std::map<std::string, optix::Program> m_mapOfPrograms;
m_mapOfPrograms[“boundingbox”] = m_context->createProgramFromPTXFile(“…/ptx/boundingbox.ptx”, “boundingbox”);

with my folders looking like:

…(some folders)
bin(here is the .exe)
…(some more folders)
ptx(here is boundingbox.ptx)

Any idea why the file is not found?

If the file is not found under the relative path “…/ptx/boundingbox.ptx”, then ask yourself what the current working directory is from which the “…/” starts.
E.g. when running from inside the Visual Studio debugger, make sure to set the current working directory to the absolute location of your “bin” folder inside the debug options.

Ok, i still can’t figure out which direction to choose, but in general it should also work, if i just give the whole path of the file, shouldn’t it?

So like “G:\something\something\build-win32-x64(in here are my binaries)\ptx\boundingbox.ptx”

Ok if i use the whole path, i get “RT_ERROR_INVALID_SOURCE”, does that mean that there’s something wrong with my .ptx file?

Yes, absolute paths would work on your specific machine, if you gave it the correct one.
If that is your actual code, you formatted the string incorrectly.
Read a C++ programming guide about “escape characters”

So you programmed something and it didn’t work?
Maybe provide some more exact details about what your code looks like.

ok, i got everything working, i used the wrong .ptx files for my cuda version in the end.

Thank you.