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 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?
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.
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.