【问题标题】:Generate header dependencies for cuda files为 cuda 文件生成头文件依赖项
【发布时间】:2013-10-04 01:19:01
【问题描述】:

我想为我的 CUDA 源文件生成头文件依赖项,以将其包含到 makefile 中。

我尝试使用以下代码:

g++ -MM my_cuda_file.cu

这适用于 .cpp 和 .h 文件,但对于 .cu 文件,我只会收到以下错误:

g++: warning: my_cuda_file.cu: linker input file unused because linking not done

我怎样才能让它工作?

我也尝试了以下代码,但它们都不起作用:

nvcc -MM my_cuda_file.cu
nvcc -Xcompiler "-MM" my_cuda_file.cu

【问题讨论】:

    标签: cuda g++ makefile


    【解决方案1】:

    引用CUDA编译器驱动nvcc参考指南:

    2.4。支持的阶段

       make dependency generation `-M` 
    

    3.2.1。指定编译阶段的选项

        --generate-dependencies    -M     Generate for the one .c/.cc/.cpp/.cxx/.cu 
                                          input file (more than one are not allowed 
                                          in this step) a dependency file that can 
                                          be included in a make file.
    

    3.2.2。文件和路径规范

         --output-directory        -odir  Specify the directory of the output file. 
                                          This option is intended for letting the
                                          dependency generation step (--generate-dependencies) 
                                          generate a rule that defines the target 
                                          object file in the proper directory.
    

    3.2.5。引导编译器驱动程序的选项

         --dependency-drive-prefix -ddp   On Windows platforms, when generating
                                            dependency files (option -M), all file names 
                                            must be converted to whatever the used 
                                            instance of make will recognize. Some 
                                            instances of make have trouble with the 
                                            colon in absolute paths in native Windows                     
                                            format, which depends on the environment in 
                                            which this make instance has been compiled. 
                                            Use -ddp /cygwin/ for a CygWin make, and -ddp / 
                                            for Mingw. Or leave these file names in native
                                            Windows format by specifying nothing.
    

    在该指南的第 5 章中,您可以找到一些使用示例。

    【讨论】:

    • 我应该使用-MT 生成文件还是使用-o 将其指定为目标?
    猜你喜欢
    • 1970-01-01
    • 2011-07-10
    • 2012-06-25
    • 2010-09-23
    • 2018-01-02
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 2011-01-24
    相关资源
    最近更新 更多