gpt4 book ai didi

c++ - CUDA 5.0 错误 LNK2001 : unresolved external symbol for cuda methods

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:52:46 24 4
gpt4 key购买 nike

链接器出错

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

我看到这里添加了类似的问题: Unresolved external symbols in beginners CUDA program但它已经将此信息添加到链接器。

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

源代码在这里:http://pastebin.com/DfdfSfWd(这是 Visual Studio 在为 CUDA 5.0 创建新项目时生成的示例)

[编辑]

链接器设置

Configuration Properties->Linker->General->Additional Library Directories :

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

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

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

但在属性中我看到 CUDA 有自己的 Linder,“CUDA Linker”,但没有设置

Additional Library Directories

Additional Dependencies

所以我设置了这个属性,但没有任何改变,链接器仍然有问题。

[编辑]

好的,错误是我改的时候

Configuration Properties->CUDA C/C++->Device->Code Generation

来自

compute_10,sm_10

compute_20,sm_20

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

最佳答案

好的,我找到了如何为单独的编译和链接设置项目,下面是一个项目示例:example simpleSeparateCompilation

关于c++ - CUDA 5.0 错误 LNK2001 : unresolved external symbol for cuda methods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13900798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com