Multiple Symbol definition error

Hi,

I have separate AnyHit.cu and ClosestHit.cu files that get compiled into PTX for use in Optix 7. I’m trying to follow along with the MDL SDK which uses the texture_support_cuda.h which implements a bunch of extern "C" functions that are necessary for the generated MDL direct callables.

However, if I include texture_support_cuda.h in both my AnyHit.cu and ClosestHit.cu I run into the following errors:
Error: Symbol 'df_bsdf_measurement_albedos' was defined multiple times. First seen in: '__closesthit__radiance_and_1_more_10907236484217499007'

I’ve also tried forward declaring these functions in the header and then creating a texture_support_cuda.cpp to link against the compiled PTX files as a library. This fixes the above error, but then the generated MDL files run into an unresolved external symbol:
Error: Unresolved external symbol 'tex_lookup_float3_2d' in module '__direct_callable__mdl_init2_and_9_more_18033467503023389813'

The SDK examples don’t have any where this header is included twice so I’m not sure what the correct solution to this problem is. Hoping for some advice. Also, apologies, I’m not sure if this belongs in the Optix section or the MDL section, but it seems MDL specific so put it here.

Thanks

Unfortunately only the OptiX people can tell, I have forwarded your question, might take a while, sorry.

Some time ago I ran into the same issue. My work-around for this simply is:
defining all OptiX programs (in your case ClosestHit and AnyHit) within the same .cu file.

@m001

Yeah, I got around the current issue by combining my ClosestHit and Anyhit within the same cu file, but this doesn’t seem like it should be the only way of making it work (it’s also not an optimal approach just in terms of code organization).