2013-10-03 49 views
0

我想为我的CUDA源文件生成头文件相关性,以将其包含在makefile中。为cuda文件生成头文件依赖关系

我试着用下面的代码:

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 

回答

3

引述CUDA编译器驱动程序NVCC参考指南:

2.4. Supported Phases

make dependency generation `-M` 

3.2.1. Options for Specifying the Compilation Phase

--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. File and Path Specifications

 --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. Options for Guiding the Compiler Driver

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