veda
veda

Reputation: 6614

CUDA: Error while compiling my first cuda program

I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong

the code

#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>

__global__ void kernel(void) {
}

int main(int argc, char *argv[])
{
        kernel<<<1,1>>>();
        printf("finished \n");
        return 0;
}

The errors are

cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token

I compiled using

nvcc cuda.c

Can anyone tell me what mistake I am making....

Upvotes: 3

Views: 2681

Answers (1)

tkerwin
tkerwin

Reputation: 9769

nvcc runs .c files through the normal C compiler. Rename your file to cuda.cu.

Upvotes: 6

Related Questions