Say I just have a very simple “main.c” file which only calls another function like “hello();” and that hello function is defined in a cu file; hello.cu.
//main.c
#include hello.h
int main(){
hello();
}
If i compile main.c with gcc, hello.cu with with nvcc, and link both with gcc, I get a “undefined reference to hello” error.
here’s the weird part though, if I name main.c as “main.cpp”, and compile main.cpp with gcc, gcc will finally link the files without complaint and the program works in the end.
Could someone please explain why this is happening, and anyway to fix it?
cuda2.3,gcc4.2.4
thanx,
tehreal