Trouble compiling helloworld.cu

后端 未结 2 1618
[愿得一人]
[愿得一人] 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 21:52

    You need to include stdio.h or cstdionot iostream (which is for std::cout stuff) for printf (see man 3 printf). I found the source code for the book here.

    chapter03/hello_world.cu is actually:

    
    /*
     * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
     *
     * NVIDIA Corporation and its licensors retain all intellectual property and 
     * proprietary rights in and to this software and related documentation. 
     * Any use, reproduction, disclosure, or distribution of this software 
     * and related documentation without an express license agreement from
     * NVIDIA Corporation is strictly prohibited.
     *
     * Please refer to the applicable NVIDIA end user license agreement (EULA) 
     * associated with this source code for terms and conditions that govern 
     * your use of this NVIDIA software.
     * 
     */
    
    
    #include "../common/book.h"
    
    int main( void ) {
        printf( "Hello, World!\n" );
        return 0;
    }
    
    

    Where ../common/book.h includes stdio.h.

    The README.txt file details how to compile the examples:

    
    The vast majority of these code examples can be compiled quite easily by using 
    NVIDIA's CUDA compiler driver, nvcc. To compile a typical example, say 
    "example.cu," you will simply need to execute:
    
    > nvcc example.cu
    

提交回复
热议问题