没有规则可以制作目标Cuda + Qt + Linux

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了没有规则可以制作目标Cuda + Qt + Linux相关的知识,希望对你有一定的参考价值。

尝试编译qt + cuda + linux并得到此错误“没有规则来制作目标'cuda_code.o',需要'../Test/Obj/cuda_code_cuda.o'。停止。”,但我会一步一步地做所有事情以下说明只是无法理解是什么错。我使用Ubuntu 18.10,Cuda编译工具V10.1.105和QT Creator 4.8.1。

main.cpp中

#include <QtCore/QCoreApplication>
#include <iostream>
using namespace std;
// the next 'include' is for CUDA error checks
#include <cuda_runtime.h>
// This is the 'elder trick of the...' - Tell the compiler this function is defined in other place
extern "C"
cudaError_t cuda_main();

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // run your cuda application
    cudaError_t cuerr = cuda_main();
    // check for errors is always a good practice!
    if (cuerr != cudaSuccess) cout << "CUDA Error: " << cudaGetErrorString( cuerr ) << endl;

    return a.exec();
}

粗大_code.粗

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
extern "C"
cudaError_t cuda_main()
{
    // generate 16M random numbers on the host
    thrust::host_vector<int> h_vec(1 << 24);
    thrust::generate(h_vec.begin(), h_vec.end(), rand);

    // transfer data to the device
    thrust::device_vector<int> d_vec = h_vec;

    // sort data on the device (805 Mkeys/sec on GeForce GTX 480)
    thrust::sort(d_vec.begin(), d_vec.end());

    // transfer data back to host
    thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());

    return cudaGetLastError();
}

和Test.pro文件

QT       += core
QT       -= gui
TARGET    = QtCuda
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE  = app
SOURCES  += main.cpp
cuda_code.cu
SOURCES -= cuda_code.cu
DESTDIR     = $$system(pwd)
OBJECTS_DIR = $$DESTDIR/Obj
QMAKE_CXXFLAGS_RELEASE =-O3
CUDA_SOURCES += cuda_code.cu
CUDA_DIR      = /usr/local/cuda-10.1
INCLUDEPATH  += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib64
LIBS += -lcudart -lcuda
CUDA_ARCH     = sm_52
NVCCFLAGS     = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -O3 -arch=$$CUDA_ARCH -c $$NVCCFLAGS 
                $$CUDA_INC $$LIBS  ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} 
                2>&1 | sed -r "s/\(([0-9]+)\)/:\1/g" 1>&2
cuda.dependency_type = TYPE_C
cuda.depend_command = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS   ${QMAKE_FILE_NAME}
cuda.input = CUDA_SOURCES
cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o
QMAKE_EXTRA_COMPILERS += cuda
答案

我重新安装qt和所有工作(我设置alpha 4.9.0和4.8.2都工作)

以上是关于没有规则可以制作目标Cuda + Qt + Linux的主要内容,如果未能解决你的问题,请参考以下文章

没有规则来制作目标.o,为啥?

*** 没有规则来制作目标 `src/main/jni/Build.config'。停止

gcc makefile错误:“没有规则来制作目标......”

Makefile:没有规则来制作目标。停止

linux C++ gmake“没有规则来制作目标”

驱动程序未编译“没有规则来制作目标”