Error "Undefined reference to main" while compiling .cu file

Hi ,

My goal is to implement a math problem in cuda by using mpi on a 3 node cluster with one frontend with no cuda on it and two compute nodes with cuda and GPU’s inside them.

I have written a MPI and CUDA program. The cuda file is kernel.cu and the mpi file is mpi.c. I called a function called run_kernel from mpi.c and the run_kernel function is defined in kernel.cu . The main function is present in mpi.c and this main function calls the run_kernel function in kernel.cu . In kernel.cu file I defined run_kernel function as extern “C” function.

When i compile the kernel.cu file by using

$ nvcc -arch=sm_11 kernel.cu (compiled like this Since I used atomicadd function)

The error it gives is

/usr/lib/gcc/i386-redhat-linux/4.1.2/…/…/…/crt1.o: In function _start': (.text+0x18): undefined reference to main’
collect2: ld returned 1 exit status

Any idea please help i was struck.

use nvcc -c

use nvcc -c

Thank you very much for your reply.

If I use nvcc -c then it is giving an error “atomicadd undefined”. So this the reason Why I used

nvcc -arch=sm_11 kernel.cu

If I compile the code on a single compute node then it works fine. i think the problem right now is not having main function in kernel.cu. `I put the main function in mpi.c file which calls kernel.cu

please help me

If u want i can forward the source code.

Thank you very much for your reply.

If I use nvcc -c then it is giving an error “atomicadd undefined”. So this the reason Why I used

nvcc -arch=sm_11 kernel.cu

If I compile the code on a single compute node then it works fine. i think the problem right now is not having main function in kernel.cu. `I put the main function in mpi.c file which calls kernel.cu

please help me

If u want i can forward the source code.

Just combine the two options:
[font=“Courier New”]nvcc -arch sm_11 -c[/font]

Just combine the two options:
[font=“Courier New”]nvcc -arch sm_11 -c[/font]

Thank you very much the code works. Thank u one more time for the awesome support.

Thank you very much the code works. Thank u one more time for the awesome support.