nvcc outputs mangled names CUDA compilation

Hi All,

I have some C++ source files which call external CUDA functions. But when I try linking the cpp obj files with cu obj files g++ linker throws lot of undefined symbols errors. Did a nm on the .cu obj files and it returns some thing like __Z22Pf where the g++ linker is searching for _.
Any ideas on how to disable name mangling when compiling with nvcc.

Thanks
Radha

Wrap the functions like so:

extern "C"

{

int someFunct(...)

{

...

}

}

or, simply do:

extern "C" int someFunct(..)

{

..

}

No more name mangling.

Thanks for the reply. I did wrap all the cuda functions calls from cpp files as extern “C”. Do you mean to say wrap functions declaration in .cu files as extern C?

Regards

Radha

alternately, just don’t use extern “C” anywhere and stick to extern if you’re linking with C++.

Tried that didn’t seem to work.

Thanks for the ideas. I did wrap all the cuda functions in .cu files and the cuda function calls in .cpp files as extern “C” but still g++ linking complains about undefined symbols. And nm on object files shows the function names are not mangled. Any ideas please share.

Thanks

Radha

Got it…extern “C” worked but in addition to that while compiling with nvcc added -m32 and while linking -m32 and -arch i386 (Mac OS Snow Leopard). I was linking with OpenCV libs as well and had to re-compile OpenCV libs with -m32 and -arch i386 in order to link properly. Previously when linking to OpenCV libs compiled without -m32 and -arch i386 the linker could not see any of the OpenCV symbols.

Thanks