CUDA 5 linker doesn't find header files

Hi all,
this is a highly primitive test example that used to work with CUDA 4.2. With CUDA 5, I get “undefined reference” errors when trying to access functions declared in gpu.h and defined in gpu.cu. Below are the three source files that are used within Nsight Eclipse edition on Linux. All CUDA libraries are included in the project settings and all source files are in the same (root) directory of the project.
The linker error is "undefined reference to run_kernel ".

I ended up with this small sample to test a problem in a large project and got stuck with an apparently primitive setup… If anyone could suggest why it can’t link, I would very much appreciate it.

/* main.c /
#include “gpu.h”
int main(int argc, char
argv){
run_kernel();
return 0;
}

/* gpu.h */
void run_kernel();

/* gpu.cu */
#include <cuda.h>
#include “gpu.h”

global void compute(){
//code
}

void run_kernel(){
compute<<<1,1>>>();
}

did you try to compile and link it manually in a terminal session?

compilation is fine from the command line, the problem is linking.
Here’s the command: /usr/local/cuda-5.0/bin/nvcc -L/usr/local/cuda-5.0/lib64 -Xlinker -O3 -link -o “Test” ./gpu.o ./main.o -lcudart

The new linker introduced in CUDA 5 doesn’t seem to find the header file with the function declaration. Do I need to use a different setup with the new linker? Or is there an error in the code?
Can you reproduce the error with CUDA 5? How would you rearrange the code to work with CUDA 5?
In the real application, I need standard C code to process the input and create host-side data structures and then call GPU code from a separate function.

I found the answer. Apparently, Nvidia didn’t bother to mention that now ALL source files are supposed to end with the *.cu or *.cpp extension. Anything with a *.c doesn’t link correctly.

I’ve searched through the programming guide and there is NOTHING there about file extensions! In many cases it’s a non-issue, but apparently sometimes it can be a problem. And total lack of documentation in this regard is unacceptable.

.cu files have always been treated as C++ source files. Therefore name mangling is enforced on all C++
external functions. If you want to call a function in a .cu file from a .c file, you must ‘extern “c”’ it
in the header file that exports it.