Cannot compile examples from 'Cuda by Example'

Hello everyone. I am trying to get some of the first examples from Cuda by Example to compile via nvcc, with no luck.

Whether I include book.h or not, I get 76 errors, most of which are similar to one of the following:

Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h(184): error: invalid redeclaration of type name “size_t”

Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime_new.h(66): error: first parameter of allocation function must be of type “size_t”

Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits(168): error: class template “std::_Is_function” has already been defined

nvidia gpu computing toolkit\cuda\v10.0\include\sm_20_intrinsics.hpp(108): error: asm operand type size(8) does not match type/size implied by constraint ‘r’

The example I am trying to compile is attached at the end of this message. Any suggestions are welcome. I have been using the command nvcc Example25.cu 2> log.txt to compile. This may not be the right way to do things, and if so please point me to detailed instructions.

Thanks!

------CODE-------

#include “cuda_by_example_download/common/book.h”

//#include <stdio.h>
//#include <cuda.h>

global void add( int a, int b, int *c){
*c = a+b;
}

int main(void){
int c;
int dev_c;
cudaMalloc( (void
*)&dev_c, sizeof(int) );

add<<<1,1>>>(2, 7, dev_c);

cudaMemcpy(
	&c,
	dev_c,
	sizeof(int),
	cudaMemcpyDeviceToHost
);

printf("2+7= %d\n", c);
cudaFree(dev_c);

return 0;

}

Well, as usual the solution was found on SO by googling my error message. Link is https://stackoverflow.com/questions/12843846/problems-when-running-nvcc-from-command-line

The command that worked was to specify a path to a particular version of cl.exe. This worked for me:

nvcc -ccbin “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64” Example25.cu