“链接器输入文件未使用的,因为链接尚未完成”试图安装Qt Creator的&放时; CUDA [英] 'linker input file unused because linking not done' when trying to setup QT creator & Cuda

查看:638
本文介绍了“链接器输入文件未使用的,因为链接尚未完成”试图安装Qt Creator的&放时; CUDA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上手使用C和CUDA使用Qt创建者的IDE。不幸的是我有从一开始的问题,不知道从哪里它来自哪里(如果它开始逐渐这将会是更容易识别)。

I'm trying to get started with with C and Cuda using QT creator as the IDE. Unfortunately I'm having problems from the start and not sure where its coming from(if it started gradually it'd be easier to identify).

我基本上已经安装CUDA(和C),并已小试运行的程序,但我想用一个IDE,所以我使用上的指示安装Qt Creator的:的 HTTP://cudaspace.word$p$pss.com/2011/04/07/qt-creator-cuda -linux / 但运行的例子,当我得到错误:连接器输入文件,未使用的,因为链接尚未完成

I basically already installed CUDA(and c) and had small test programs running but I wanted to use an IDE so I installed QT creator using the instructions on: http://cudaspace.wordpress.com/2011/04/07/qt-creator-cuda-linux/ but I'm getting errors when running the example: 'linker input file unused because linking not done'

下面的所有文件(与我的修改,因为我使用的是MAC和说明适用于Linux操作系统。我可以编译基本的Hello World 类的东西,但不是例子因为某些原因):
my_first_project.pro:

Here's all the files(with my modifications since I'm using a mac and the instructions are for linux. I can compile basic hello world type things but not the example for some reason): my_first_project.pro:

TEMPLATE = app
LANGUAGE = C++
CONFIG += qt4


SOURCES += main.cpp \
    cuda_interface.cu
# Cuda sources
CUDA_SOURCES += cuda_interface.cu
# Project dir and outputs
PROJECT_DIR = $$system(pwd)
OBJECTS_DIR = $$PROJECT_DIR/Obj
DESTDIR = ../bin

# Path to cuda SDK install
CUDA_SDK = /Users/lostsoul/Dropbox/qt_cuda/C/
# Path to cuda toolkit install
CUDA_DIR = /usr/local/cuda
# GPU architecture
CUDA_ARCH = compute_10
# nvcc flags (ptxas option verbose is always useful)
NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
# include paths
INCLUDEPATH += $$CUDA_DIR/include
INCLUDEPATH += $$CUDA_SDK/common/inc/
INCLUDEPATH += $$CUDA_SDK/../shared/inc/
# lib dirs
QMAKE_LIBDIR += $$CUDA_DIR/lib64
QMAKE_LIBDIR += $$CUDA_SDK/lib
QMAKE_LIBDIR += $$CUDA_SDK/common/lib
# libs - note than i'm using a x_86_64 machine
LIBS += -lcudart -lcutil_x86_64
# join the includes in a line
CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
LD_LIBRARY_PATH = /usr/local/cuda/lib

# Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part)
cuda.input = CUDA_SOURCES
cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o

cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -g -G -arch=$$CUDA_ARCH -c $$NVCCFLAGS $$CUDA_INC $$LIBS  ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}

cuda.dependcy_type = TYPE_C
cuda.depend_command = $$CUDA_DIR/bin/nvcc -g -G -M $$CUDA_INC $$NVCCFLAGS   ${QMAKE_FILE_NAME}
# Tell Qt that we want add more stuff to the Makefile
QMAKE_EXTRA_COMPILERS += cuda

cuda_interface.cu:

cuda_interface.cu:

// CUDA-C includes
#include <cuda.h>
#include <cutil_inline.h>

extern "C"
void runCudaPart();

// Main cuda function

void runCudaPart() {

// all your cuda code here *smile*

}

main.cpp中:

main.cpp:

#include <QtCore/QCoreApplication>

// This is the 'elder trick of the...' - Tell the compiler this function is defined in other place
extern "C"
void runCudaPart();

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

    QCoreApplication a(argc, argv);

    runCudaPart();

    return a.exec();

}

下面是错误的输出:

09:24:27: Running build steps for project first_project...
09:24:27: Configuration unchanged, skipping qmake step.
09:24:27: Starting: "/usr/bin/make" -w
make: Entering directory `/Users/lostsoul/Dropbox/qt_cuda/first_project-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug'
/usr/local/cuda/bin/nvcc -m64 -g -G -arch=compute_10 -c --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v -I/usr/local/cuda/include -I/Users/lostsoul/Dropbox/qt_cuda/C//common/inc/ -I/Users/lostsoul/Dropbox/qt_cuda/C//../shared/inc/ -lcudart -lcutil_x86_64 ../first_project/cuda_interface.cu -o ../first_project/Obj/cuda_interface_cuda.o
g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/macx-g++ -I../first_project -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/Headers -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include/QtGui -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/cuda/include -I../C/common/inc -I/Users/lostsoul/Dropbox/qt_cuda/C//../shared/inc/ -I. -I../first_project -I. -F/Users/lostsoul/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o ../first_project/Obj/main.o ../first_project/main.cpp
gcc -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/macx-g++ -I../first_project -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/Headers -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include/QtGui -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/cuda/include -I../C/common/inc -I/Users/lostsoul/Dropbox/qt_cuda/C//../shared/inc/ -I. -I../first_project -I. -F/Users/lostsoul/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o ../first_project/Obj/cuda_interface.o ../first_project/cuda_interface.cu
i686-apple-darwin11-llvm-gcc-4.2: ../first_project/cuda_interface.cu: linker input file unused because linking not done
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o ../bin/first_project.app/Contents/MacOS/first_project ../first_project/Obj/cuda_interface_cuda.o ../first_project/Obj/main.o ../first_project/Obj/cuda_interface.o   -F/Users/lostsoul/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L/usr/local/cuda/lib64 -L/Users/lostsoul/Dropbox/qt_cuda/C//lib -L/Users/lostsoul/Dropbox/qt_cuda/C//common/lib -L/Users/lostsoul/QtSDK/Desktop/Qt/4.8.1/gcc/lib -lcudart -lcutil_x86_64 -framework QtGui -L/usr/local/pgsql/lib -L/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -F/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -framework QtCore 
i686-apple-darwin11-llvm-g++-4.2: ../first_project/Obj/cuda_interface.o: No such file or directory
make: *** [../bin/first_project.app/Contents/MacOS/first_project] Error 1
make: Leaving directory `/Users/lostsoul/Dropbox/qt_cuda/first_project-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug'
09:24:33: The process "/usr/bin/make" exited with code 2.
Error while building project first_project (target: Desktop)
When executing build step 'Make'

我一直在努力想出解决办法的最后几个小时,我真的不知道该如何处理这个。我认为唯一的办法就是也许我化妆的版本是指令太新了(因为我也跟着教程是从去年开始),但似乎命令来执行。我真的很新的C / CUDA和Qt Creator的和我唯一的目标是执行C / C ++和放大器;对QT CUDA code(因为显然它可以编译无论是在他们相互交谈并执行code完成的一种方式)。我越深挖更加不确定我是否该错误是一个错误的QT或C错误(我不认为它是一个特定的CUDA错误,因为我真的没有任何code有)。

I've been struggling to figure this out for the last few hours and I'm really unsure how to approach this. The only thing I thought was maybe my version of make was too new for the instructions(since the tutorial I followed was from last year) but commands seemed to execute. I'm really really new to C/Cuda and QT creator and my only goal is to execute c/c++ & cuda code on QT(because apparently it can compile both in a way they talk to each other and does code completion). The more I dig deep the more unsure I am if this error is a QT error or a C error(I don't think its a CUDA specific error since I really don't have any code there).

请大家帮忙!

推荐答案

根据我们在聊天讨论中,我们发现使用CUDA SDK安装目录有问题,这样你就可以通过删除SDK相关的东西简化.pro文件。

Based on our discussion in the chat, we found a problem with the CUDA SDK installation directory, so you can simplify the .pro file by removing the SDK related stuff.

检查您的CUDA SDK安装目录(/开发/ GPU \\计算机/​​ C)的空白,因为它可能是问题的原因。

Check the blank space of your CUDA SDK installation directory (/Developer/GPU\ Computing/C) as it could be the cause of the problem.

说,该作品使用最新的软件和OSX狮子的基本配置如下:

Said that, the basic configuration that works using the latest software and osx lion is as follows:

QT += core
QT -= gui

TARGET = cuda_sample
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
# Source files for C/C++ compiler
SOURCES += main.cpp
# project build directories
DESTDIR = $$system(pwd)
OBJECTS_DIR = $$DESTDIR/Obj
# and C/C++ flags
QMAKE_CFLAGS_RELEASE =-O3
QMAKE_CXXFLAGS_RELEASE =-O3
# cuda source
CUDA_SOURCES += cuda_interface.cu
# Path to cuda toolkit install
CUDA_DIR = /usr/local/cuda
INCLUDEPATH += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib
# GPU architecture
CUDA_ARCH = sm_20
# NVCC flags
NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
# Path to libraries
LIBS += -lcudart -lcuda
# join the includes in a line
CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
# Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part)
cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -O3 -arch=$$CUDA_ARCH -c $$NVCCFLAGS $$CUDA_INC $$LIBS ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}

cuda.dependcy_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
# Tell Qt that we want add more stuff to the Makefile
QMAKE_EXTRA_COMPILERS += cuda

由于我们没有使用CUDA SDK库,从cuda_interface.cu删除文件以下行

As we are not using the CUDA SDK libs, remove from your cuda_interface.cu file the following line

#include <cutil_inline.h> // remove this line from your file

这就是全部。记住运行的qmake采取.pro文件的变化。

That's all. Remember run qmake to take the changes of the .pro file.

这篇关于“链接器输入文件未使用的,因为链接尚未完成”试图安装Qt Creator的&放时; CUDA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆