为cuda文件生成标头依赖项

时间:2013-10-03 16:59:33

标签: cuda g++ makefile

我想为我的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

1 个答案:

答案 0 :(得分:3)

引用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章中,您可以找到一些使用示例。