歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

centos系統下,Qt中使用openGL和cuda,.pro需要配置的庫和頭文件

#CONFIG+= qt opengl warn_on release

TEMPLATE = app

CONFIG += console c++11

CONFIG -= app_bundle

CONFIG -= qt

# this is the important part 配置openGL連接庫,很重要,否則會出現 未定義引用的...

linux|win32: LIBS += -lGLU

linux|win32: LIBS += -lGL

linux|win32: LIBS += -lglut

SOURCES += main.cpp \

vector.cpp \

particle.cpp \

mtime.cpp \

merror.cpp \

mdebug.cpp \

matrix.cpp \

image.cpp \

particle_system.cpp \

GLee.c

HEADERS += \

vector-inline.h \

vector.h \

particle_system.h \

particle.h \

mtime.h \

merror.h \

mdebug.h \

matrix-inline.h \

matrix.h \

image.h \

GLee.h \

#cuda配置

# 讓你的項目可以看到後綴cu的cuda代碼文件,cudatest.cu是你創建的項目

OTHER_FILES += cudatest.cu \

# CUDA配置,具體按照你系統環境更改

CUDA_SOURCES += cudatest.cu \

CUDA_SDK = "/usr/local/cuda-7.5/samples/" # cudaSDK路徑

CUDA_DIR = "/usr/local/cuda-7.5/" # CUDA tookit路徑

SYSTEM_NAME = x64 # 自己系統環境 'Win32', 'x64', or 'Win64'

SYSTEM_TYPE = 64 #操作系統位數 '32' or '64',

CUDA_ARCH = sm_21 # cuda架構, for example 'compute_10', 'compute_11', 'sm_10'

NVCC_OPTIONS = --use_fast_math

# include paths

INCLUDEPATH += /usr/local/cuda/include \

/usr/local/cuda/samples/common/inc/

LIBS += /usr/local/cuda/lib64/libcudart.so \

/usr/local/cuda/lib64/libcufft.so \

/usr/local/cuda/lib64/libcuinj64.so \

/usr/local/cuda/lib64/libcurand.so \

/usr/local/cuda/lib64/libcusparse.so \

/usr/local/cuda/lib64/libnppc.so \

/usr/local/cuda/lib64/libnppi.so \

/usr/local/cuda/lib64/libnpps.so \

/usr/local/cuda/lib64/libnvToolsExt.so

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 = cudart cufft

# 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 -O3 -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}

cuda.dependency_type = TYPE_C

QMAKE_EXTRA_COMPILERS += cuda

Copyright © Linux教程網 All Rights Reserved