0

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

1 回答 1

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

于 2013-10-03T17:06:31.387 回答