本文介绍了CUDA 5.0错误LNK2001:cuda方法的未解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在链接器中有错误

1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>kernel.cu.obj : error LNK2001: unresolved external symbol _cudaMalloc@8
1>kernel.cu.obj : error LNK2001: unresolved external symbol _cudaFree@4

我在这里看到类似的问题:

但它已经将此信息添加到链接器。

I saw similar question added here :Unresolved external symbols in beginners CUDA programBut it's already have added this information to linker.

那么问题在哪里?
我使用Visual Studio 2010 Premium与CUDA SDK 5.0和Nsight 3.0 for VS

So where is the problem ?I'm using Visual Studio 2010 Premium with CUDA SDK 5.0 and Nsight 3.0 for VS

源代码在这里:
(这是Visual Studio为CUDA 5.0创建的新项目生成的示例)

Source code here : http://pastebin.com/DfdfSfWd(It's a example generated by Visual Studio on created new project for CUDA 5.0)

链接器的设置

$(CudaToolkitLibDir)$(CUDA_LIB_PATH)$(CUDA_PATH)\lib \ $ PlatformName)

$(CudaToolkitLibDir) $(CUDA_LIB_PATH) $(CUDA_PATH)\lib\$(PlatformName)

配置属性 - >链接器 - >输入 - >附加依赖关系

Configuration Properties->Linker->Input->Additional Dependencies

cuda.lib; cudart。 lib;和其他libs。

cuda.lib;cudart.lib; and the other libs..

但是在属性中我看到CUDA拥有自己的Linder,CUDA链接器 / p>

But in properties I see that CUDA haves own Linder, "CUDA Linker" and that doesnt have set

p>

and

但是没有什么改变,链接器仍然有问题。

so I set this properties but nothing that change, the linker still have problem.

我更改

来自

并为CUDA C / C ++添加标志-dc

and add a flag -dc for CUDA C/C++

推荐答案

如何设置项目为独立编译&链接,下面我们有一个工程的例子:

Ok, I found how to set the project for Separate Compilation & Linking, below we have an example of project where it work :example simpleSeparateCompilation

这篇关于CUDA 5.0错误LNK2001:cuda方法的未解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:15