Compiling CUDA and CPP files in Linux

Hi,

I was developing my code in Visual Studio but now i want to run the same code in Linux environment and i am stuck with the compilation problem.

I tried to refer to the web and make a make file that compiles my code but i couldn’t do it.

Basically i have following files:-

  1. kernel.cu // this file contains all the kernel functions.
  2. warp.cpp // this file contains the wrapper function(global) that calls the kernel functions in kernel.cu files. kernel.cu is included in this file.
  3. main.cpp // this file contains opengl methods and calls the methods in warp.cpp using common header file ( global_methods.h)
  4. global_methods.h // common header containing extern functions, that is included in warp.cpp and main.cpp

I have included cuda.h in warp.cpp.

Can anyone let me know how to compile files under this configuration?

I have tried compiling using following links:- but it doesnt seem to work

http://gpuray.blogspot.com/2009/07/compili…a-projects.html
http://stackoverflow.com/questions/1607015…ing-under-linux

I would be very grateful if anyone can show me the right path or give me a makefile.

thank you
miztaken

If warp.cpp #includes the source of kernel.cu and contains actual runtime API kernel calls, you will have to rename it warp.cu and compile it with nvcc. The compiler driver relies on the file extension to determine whether parse CUDA code and invoke the device compiler on it. If the extension is .cpp, it will just try and compile as host code.

If warp.cpp #includes the source of kernel.cu and contains actual runtime API kernel calls, you will have to rename it warp.cu and compile it with nvcc. The compiler driver relies on the file extension to determine whether parse CUDA code and invoke the device compiler on it. If the extension is .cpp, it will just try and compile as host code.

Oh i made a mistake in above post… i mistyped the extension my warp.cpp is warp.cu already. its not .cpp its cu.

what i am doing is trying to compile cpp first

then trying to cu files.

then trying to merge them as shown in the link i have provided… compiling individually works but while merging it… it fails with a page or two of errors… all related to cuda.

i am stuck in this problem.

Oh i made a mistake in above post… i mistyped the extension my warp.cpp is warp.cu already. its not .cpp its cu.

what i am doing is trying to compile cpp first

then trying to cu files.

then trying to merge them as shown in the link i have provided… compiling individually works but while merging it… it fails with a page or two of errors… all related to cuda.

i am stuck in this problem.

Merging? Do you mean linking? If you do mean linking, can you at least show the linking command you are trying and the first few lines of errors that are produced by it.

Merging? Do you mean linking? If you do mean linking, can you at least show the linking command you are trying and the first few lines of errors that are produced by it.