I've seen many old tries to combine QtCreator with CUDA, but they all don't work anymore.
So I'm starting this topic so that there could be a new reference for everyone.
First, I tried to compile the code like the book mentions, with the following command:
nvcc seqCuda.cu -o seqCuda
But I got the error: invalid redecleration of type name "size_t".
The only thing I was able to do was compiling this sample code from the book "CUDA Application Design and Development" using Visual Studio 2010; however, VS2010 isn't the environment I wanna use. So I went to log files and took the execution command it uses, and it's the following:
nvcc -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\include" --keep-dir "Release" -maxrregcount=0 --machine 32 --compile -Xcompiler "/EHsc /nologo /Od /Zi /MD " -o "Release\main.cu.obj" "C:\Users\Sam\Documents\Visual Studio 2010\Projects\CUDA_TestVS2010\CUDA_TestVS2010\main.cu"
This command creates an object file. I could execute it for the sample code from seqCuda.cu successfully, but I don't know how to go from the object file to the executable. I want to do that in Qt using a qmake file.
Could anyone please tell me what are the important parts of this compiling command and how I can do it the merge it the right way in a qmake file?
Now my problem is, I tried to disassemble this command and rewrite it with qmake, and yes I was stabbing in the dark, and couldn't achieve any satisfying result. The following is my "try" to do that in qmake. If you could replace any of the commands in the following qmake with environment variables, I'd be thankful, especially the VC2010 bin dir.
win32 {
INCLUDEPATH += $(CUDA_INC_PATH)
QMAKE_LIBDIR += $(CUDA_LIB_PATH)
ARCFLAGS = -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env
VSVERSIONFLAGS = --cl-version 2010
VSDIRFLAG = -ccbin "c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin"
OTHERFLAGS = -maxrregcount=0 --machine 32 --compile
-Xcompiler "/EHsc /nologo /Od /Zi /MD "
LIBS += -lcudart
cuda.output = ./${QMAKE_FILE_BASE}_cuda.obj
cuda.commands = $(CUDA_BIN_PATH)/nvcc.exe $$ARCFLAGS $$VSVERSIONFLAGS $$VSDIRFLAG -
I$(CUDA_INC_DIR) $$OTHERFLAGS
}
CUDA_SOURCES += seqCuda.cu
cuda.input = CUDA_SOURCES
QMAKE_EXTRA_COMPILERS += cuda