Get error when trying to compile simple code

I bought the CUDA By Example book that came out a few weeks ago and have been trying the Hello world code but I get the following error when trying to compile.

[codebox]jake@jake-desktop:~$ nvcc hello.c

hello.c:1:28: error: …/common/book.h: No such file or directory

hello.c: In function ‘main’:

hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’[/codebox]

Likewise, when I try to compile the 2nd Hello World example I get the following error.

[codebox]hello.c:2:20: error: iostream: No such file or directory

hello.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’

hello.c: In function ‘main’:

hello.c:8: error: expected declaration specifiers before ‘kernel’

hello.c:9: error: expected declaration specifiers before ‘printf’

hello.c:10: error: expected declaration specifiers before ‘return’

hello.c:12: error: expected declaration specifiers before ‘}’ token

hello.c:12: error: expected ‘{’ at end of input[/codebox]

I expect you need some additional code to get the first sample to compile. It looks like they are available for download here.

In the second example it looks like you are trying to compile C++ code using a C compiler.

I expect you need some additional code to get the first sample to compile. It looks like they are available for download here.

In the second example it looks like you are trying to compile C++ code using a C compiler.