我正在尝试让 CUDA 代码在 Ubuntu 12.04 上与 Qt 一起使用
我的 cuda_interface.cu
// CUDA-C includes
#include <cuda.h>
extern "C"
void runCudaPart();
// Main cuda function
void runCudaPart() {
// all your cuda code here *smile*
}
我的 main.cpp #include
extern "C"
void runCudaPart();
int main(int argc, char *argv[])
{
runCudaPart();
}
我的简历
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-17T10:50:37
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = QtCuda
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# This makes the .cu files appear in your project
OTHER_FILES += ./cuda_interface.cu
# CUDA settings <-- may change depending on your system
CUDA_SOURCES += ./cuda_interface.cu
CUDA_SDK = "/usr/local/cuda-5.0/" # Path to cuda SDK install
CUDA_DIR = "/usr/local/cuda-5.0/" # Path to cuda toolkit install
SYSTEM_NAME = unix # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 32 # '32' or '64', depending on your system
CUDA_ARCH = sm_21 # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
NVCC_OPTIONS = --use_fast_math
# include paths
INCLUDEPATH += $$CUDA_DIR/include
# library directories
QMAKE_LIBDIR += $$CUDA_DIR/lib/
CUDA_OBJECTS_DIR = ./
# The following library conflicts with something in Cuda
#QMAKE_LFLAGS_RELEASE = /NODEFAULTLIB:msvcrt.lib
#QMAKE_LFLAGS_DEBUG = /NODEFAULTLIB:msvcrtd.lib
# Add the necessary libraries
CUDA_LIBS = libcuda libcudart
# The following makes sure all path names (which often include spaces) are put between quotation marks
CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"')
NVCC_LIBS = $$join(CUDA_LIBS,' -l','-l', '')
LIBS += $$join(CUDA_LIBS,'.so ', '', '.so')
# 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 -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$NVCC_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 $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda
}
我正在尝试从Compiling Cuda code in Qt Creator on Windows中采用这个 .pro 文件, 这是一个类似的问题,但正在寻求 Windows 的解决方案。
目前编译器显示以下错误:
make: Entering directory `/home/swaroop/Work/ai-junkies/cuda/uc_davis/opencv2.x/QtCuda'
g++ -Wl,-O1 -o QtCuda cuda_interface_cuda.o main.o -L/usr/local/cuda-5.0//lib/ -L/usr/lib/i386-linux-gnu libcuda.so libcudart.so -lQtCore -lpthread
g++: error: libcuda.so: No such file or directory
g++: error: libcudart.so: No such file or directory
make: *** [QtCuda] Error 1
请帮我解决这些问题。