My C++ project main.cpp, compiled with pgcpp from PGI, calls a function cuda() containing CUDA code in a separate file cuda.cu, compiled with nvcc. Unless I wrap the cuda() function with extern "C" in the function declaration and the common header file, I get linking errors (undefined references).
Without extern "C" (symbol name mismatch => undefined reference):
$ nm main.o | grep -y cuda
U cuda__FPfPiT2iN32
$ nm cuda.o | grep -y cuda
T _Z13cudaPfPiS0_iS0_S0_S0_
With extern "C" (symbol name match => linking works fine):
$ nm main.o | grep -y cuda
U cuda
$ nm cuda.o | grep -y cuda
T cuda
It was my impression that nvcc used the host C++ compiler for host code, and that it would therefore mangle symbol names as in C++? What am I doing wrong then?
EDIT: Could this be due to the fact that nvcc actually uses the GNU compiler gcc for host code, and that this compiler mangles names differently than pgcpp?
EDIT2: My system has pgcpp 14.9, gcc 4.4.7, nvcc/CUDA 6.5
Aucun commentaire:
Enregistrer un commentaire