Problem compiling Cuda source code

Hi everyone,

I’m a beginner and didn’t get how to compile Cuda:
I’m using the following code in a file named main.c:

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


global void kernel(void)


int main(int argc, char** argv)
printf(“Hello World\n”);

return (EXIT_SUCCESS);


With nvcc main.c I’ve got the following error :

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

I know that it seems to be simple, but I really have trouble to understand how to build and run it.

I thank you beforehand for your advice.


Cuda sources are expected to have a “.cu” extension.


Thank you for your help, the a.out file has been created.

Unfortunately, by doing ./a.out, the following message appears : ./a.out: error while loading shared libraries: cannot open shared object file: No such file or directory

Do you have any Idea about solving this?



PS : exists and is located on /opt/cuda/lib/

export LD_LIBRARY_PATH=/opt/cuda/lib:$LD_LIBRARY_PATH

it works.

Thank you !!