Trouble compiling helloworld.cu

后端 未结 2 1517
[愿得一人]
[愿得一人] 2021-01-17 21:16

While compiling this hello world sample in Ubuntu 10.10

This is from CUDA by Example, chapter 3 (No compile instructions provided >:@)

#include 

        
2条回答
  •  无人共我
    2021-01-17 22:17

    The issue is that the compiler does not know where to find printf function. It needs to know where to find it. The include directive is used to tell the compiler where to find it.

    #include "stdio.h"
    
    int main(void) {
      printf("Hello World!\n");
      return 0;
    }
    

    After the fix, it would work:

    $ nvcc hello_world.cu
    $ ls
    a.out  hello_world.cu
    $ a.out
    Hello World!
    

提交回复
热议问题