0
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-17T16:30:33
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = untitled6
TEMPLATE     = app


SOURCES += main.cpp


# This makes the .cu files appear in your project
OTHER_FILES +=  ./vectorAddition.cu

# CUDA settings <-- may change depending on your system
CUDA_SOURCES += ./vectorAddition.cu
CUDA_SDK = "C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0"   # Path to cuda SDK install
CUDA_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0"            # Path to cuda toolkit install

# DO NOT EDIT BEYOND THIS UNLESS YOU KNOW WHAT YOU ARE DOING....

SYSTEM_NAME = Win32         # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 32            # '32' or '64', depending on your system
CUDA_ARCH = sm_20           # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
NVCC_OPTIONS = --use_fast_math


# include paths
INCLUDEPATH += $$CUDA_DIR/include \
$$CUDA_DIR/lib \
$$CUDA_SDK/shared/lib/Win32


# library directories
QMAKE_LIBDIR += $$QT_INSTALL_PREFIX/../Tools/MinGW-gcc440_1/mingw/lib \
$$CUDA_DIR/common/lib

CUDA_OBJECTS_DIR = ./


# Add the necessary libraries
CUDA_LIBS = -lcuda -lcudart






# The following makes sure all path names (which often include spaces) are put between quotation marks
CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"')
#LIBS += $$join(CUDA_LIBS,'.so ', '', '.so')
LIBS += $$CUDA_LIBS \


# Configuration of the Cuda compiler
CONFIG(debug, debug|release) {
    # Debug mode
    cuda_d.input = CUDA_SOURCES
    cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
    cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
    cuda_d.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
    # Release mode
    cuda.input = CUDA_SOURCES
    cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
    cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$NVCC_OPTIONS $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
    cuda.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda
}

This is .pro file of QT. This code came from this page Compiling Cuda code in Qt Creator on Windows and this code is appropriately modified for my code.

Evenif I use this code, I have some errors.

14:52:46: Running steps for project untitled6...
14:52:46: Configuration unchanged, skipping qmake step.
14:52:46: Starting: "C:\Qt\Tools\MinGW-gcc440_1\mingw\bin\mingw32-make.exe" 
C:/Qt/Tools/MinGW-gcc440_1/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/HTLAB/Documents/build-untitled6-Unnamed-Debug'
g++ -mthreads -Wl,-subsystem,windows -o debug\untitled6.exe vectorAddition_cuda.o debug/main.o  -L"\..\Tools\MinGW-gcc440_1\mingw\lib" -L"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\common\lib" -L"c:\Qt\4.8.1\lib" -lmingw32 -lqtmaind -lcuda -lcudart -lQtCored4 
Warning: .drectve `/FAILIFMISMATCH:"_MSC_VER=1800" /FAILIFMISMATCH:"_ITERATOR_DEBUG_LEVEL=2" /FAILIFMISMATCH:"RuntimeLibrary=MTd_StaticDebug" /DEFAULTLIB:"libcpmtd" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
vectorAddition_cuda.o:(.text$mn+0x2a): undefined reference to `_hypotf'
vectorAddition_cuda.o:(.text$mn+0x4a): undefined reference to `__security_cookie'
vectorAddition_cuda.o:(.text$mn+0x1ab): undefined reference to `@__security_check_cookie@4'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\untitled6.exe] Error 1
mingw32-make: *** [debug] Error 2
mingw32-make[1]: Leaving directory `C:/Users/HTLAB/Documents/build-untitled6-Unnamed-Debug'
14:52:46: The process "C:\Qt\Tools\MinGW-gcc440_1\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project untitled6 (kit: Unnamed)
When executing step "Make"
14:52:46: Elapsed time: 00:00.

What should I do?

Community
  • 1
  • 1
Jeagun
  • 1
  • 1
  • Try changing the build to 64 bit. 32 bit builds are pretty much deprecated on Windows platforms – talonmies Jul 20 '16 at 06:09
  • Try prepending `-L$$CUDA_DIR/lib` before your libraries within the $$CUDA_LIBS (LIBS) variable. The linker won't know where to find them – Sebastian Lange Jul 20 '16 at 06:13
  • @talonmies chage 32bit to 64bit make an error; vectorAddition_cuda.o: file not recognized: File format not recognized – Jeagun Jul 20 '16 at 06:32
  • @SebastianLange I insert the -L$$CUDA_DIR/lib code before $$CUDA_LIBS but, there is another error; (....) C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/include" -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib" -I"C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0/shared/lib/Win32" -LC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib -lcuda -lcudart --machine 32 -arch=sm_20 -c -o vectorAddition_cuda.o ..\untitled6\vectorAddition.cu **nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified** – Jeagun Jul 20 '16 at 06:35
  • Add double ticks to the library path. "GPU" and "Computing" and "Toolkit....lib" are seen as source files, since the path contains spaces. => `-L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib"` – Sebastian Lange Jul 20 '16 at 06:47
  • @SebastianLange I insert that code and delete all space on directory. Then I get the same error message as first one. "undefined reference to `_hypotf' ..... " I think I should insert more library file, but I don't know what's the library that should be included. In main file, #include In cuda file, #include #include #include – Jeagun Jul 20 '16 at 07:22
  • I read that gcc could make trouple under windows using cuda. Some things i would try: If it is possible for you try the same with native MSVC compiler. Are the missing functions mentioned in the DLL? Try reimping the cuda library for MinGW usage? – Sebastian Lange Jul 20 '16 at 07:35
  • 1
    The only officially supported compiler for compiling/linking operations on the windows platform for CUDA is `cl.exe` that is part of visual studio. Using g++ for compiling or linking operations is not officially supported on windows. – Robert Crovella Jul 20 '16 at 15:54

0 Answers0