QtCreator qmake with nvcc and CUDA, Windows 7

I have seen many old attempts to combine QtCreator with CUDA, but all of them no longer work.

So, I am starting this thread so that a new link appears for everyone.

First, I tried to compile the code, as mentioned in the book, with the following command:

nvcc seqCuda.cu -o seqCuda

But I got an error: invalid reuse of a name like "size_t".

The only thing I could do was compile this sample code from the book "Developing and Developing CUDA Applications" using Visual Studio 2010; however, VS2010 is not the environment that I want to use. So I went to the log files and took the executable command that it uses, and this is 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 can execute it for 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 this in Qt using the qmake file.

Can someone please tell me what are the important parts of this compilation command and how can I do this to merge it into the qmake file correctly?

Now my problem is that I tried to parse this command and rewrite it with qmake, and yes, I was a knife in the dark and could not achieve a satisfactory result. The following is my "attempt" to do this in qmake. If you could replace any of the commands in the next qmake with environment variables, I would be grateful, especially the VC2010 bin file.

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
+5
source share

All Articles