<i id='6Ftww'><tr id='6Ftww'><dt id='6Ftww'><q id='6Ftww'><span id='6Ftww'><b id='6Ftww'><form id='6Ftww'><ins id='6Ftww'></ins><ul id='6Ftww'></ul><sub id='6Ftww'></sub></form><legend id='6Ftww'></legend><bdo id='6Ftww'><pre id='6Ftww'><center id='6Ftww'></center></pre></bdo></b><th id='6Ftww'></th></span></q></dt></tr></i><div id='6Ftww'><tfoot id='6Ftww'></tfoot><dl id='6Ftww'><fieldset id='6Ftww'></fieldset></dl></div>
<legend id='6Ftww'><style id='6Ftww'><dir id='6Ftww'><q id='6Ftww'></q></dir></style></legend><tfoot id='6Ftww'></tfoot>
    <bdo id='6Ftww'></bdo><ul id='6Ftww'></ul>

      1. <small id='6Ftww'></small><noframes id='6Ftww'>

      2. 初学者 CUDA 程序中未解析的外部符号

        时间:2023-12-03
              <bdo id='DRqc1'></bdo><ul id='DRqc1'></ul>

              <legend id='DRqc1'><style id='DRqc1'><dir id='DRqc1'><q id='DRqc1'></q></dir></style></legend>
            • <tfoot id='DRqc1'></tfoot>

                  <tbody id='DRqc1'></tbody>
              1. <i id='DRqc1'><tr id='DRqc1'><dt id='DRqc1'><q id='DRqc1'><span id='DRqc1'><b id='DRqc1'><form id='DRqc1'><ins id='DRqc1'></ins><ul id='DRqc1'></ul><sub id='DRqc1'></sub></form><legend id='DRqc1'></legend><bdo id='DRqc1'><pre id='DRqc1'><center id='DRqc1'></center></pre></bdo></b><th id='DRqc1'></th></span></q></dt></tr></i><div id='DRqc1'><tfoot id='DRqc1'></tfoot><dl id='DRqc1'><fieldset id='DRqc1'></fieldset></dl></div>

                • <small id='DRqc1'></small><noframes id='DRqc1'>

                  本文介绍了初学者 CUDA 程序中未解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个新的 Win32 控制台应用程序作为一个空项目我正在使用 Visual Studio 2008 C++ 运行 Windows 7 64 位.我试图从本文底部获取示例代码来构建:http://www.ddj.com/architect/207200659

                  我将 CUDA Build Rule v2.3.0 添加到项目的自定义构建规则中.它是可用规则文件列表中唯一带有复选框的东西

                  我在源文件(文件夹/过滤器???)中创建了 moveArrays.cu

                  在该文件中,我添加以下代码:

                  //moveArrays.cu////演示 CUDA 接口到设备(GPU)上的数据分配//以及主机(CPU)和设备之间的数据移动.#include #include #include int main(void){浮动*a_h,*b_h;//指向主机内存的指针浮动 *a_d, *b_d;//指向设备内存的指针整数 N = 14;国际我;//在主机上分配数组a_h = (float *)malloc(sizeof(float)*N);b_h = (float *)malloc(sizeof(float)*N);//在设备上分配数组cudaMalloc((void **) &a_d, sizeof(float)*N);cudaMalloc((void **) &b_d, sizeof(float)*N);//初始化主机数据对于 (i=0; i

                  构建时出现以下错误:

                  <前>1>------ 构建开始:项目:CUDASandbox,配置:调试 x64 ------1>链接...1>moveArrays.cu.obj : error LNK2019: 函数 main 中引用了未解析的外部符号 cudaFree1>moveArrays.cu.obj : error LNK2019: 函数 main 中引用了未解析的外部符号 cudaMemcpy1>moveArrays.cu.obj : error LNK2019: 函数 main 中引用了未解析的外部符号 cudaMalloc1>moveArrays.cu.obj:错误 LNK2019:未解析的外部符号 __cudaUnregisterFatBinary 在函数 __cudaUnregisterBinaryUtil 中引用1>moveArrays.cu.obj:错误 LNK2019:未解析的外部符号 __cudaRegisterFatBinary 在函数 __sti____cudaRegisterAll_45_tmpxft_00001264_00000000_6_moveArrays_cpp1_ii_main 中引用1>D:StuffProgrammingVisual Studio 2008ProjectsCUDASandboxx64DebugCUDASandbox.exe:致命错误 LNK1120:5 个未解析的外部1>构建日志保存在file://d:StuffProgrammingVisual Studio 2008ProjectsCUDASandboxCUDASandboxx64DebugBuildLog.htm"1>CUDASandbox - 6 个错误,0 个警告========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========

                  我可以编译和运行 SDK 附带的示例 CUDA 程序.我知道我在这里遗漏了一些简单的东西,但它是什么?

                  解决方案

                  我猜你没有链接到正确的库.确保在配置属性->链接器->输入"下添加了 CUDA 库.请参阅此.

                  I create a new Win32 Console App as an empty project I am running Windows 7 64bit with Visual Studio 2008 C++. I am trying to get the sample code from the bottom of this article to build: http://www.ddj.com/architect/207200659

                  I add CUDA Build Rule v2.3.0 to the project's custom build rules. It is the only thing with a checkbox in the available rule files list

                  I create moveArrays.cu in the Source Files (folder/filter???)

                  In that file I add the following code:

                  // moveArrays.cu
                  //
                  // demonstrates CUDA interface to data allocation on device (GPU)
                  // and data movement between host (CPU) and device.
                  
                  #include <stdio.h>
                  #include <assert.h>
                  #include <cuda.h>
                  int main(void)
                  {
                     float *a_h, *b_h;     // pointers to host memory
                     float *a_d, *b_d;     // pointers to device memory
                     int N = 14;
                     int i;
                     // allocate arrays on host
                     a_h = (float *)malloc(sizeof(float)*N);
                     b_h = (float *)malloc(sizeof(float)*N);
                     // allocate arrays on device
                     cudaMalloc((void **) &a_d, sizeof(float)*N);
                     cudaMalloc((void **) &b_d, sizeof(float)*N);
                     // initialize host data
                     for (i=0; i<N; i++) {
                        a_h[i] = 10.f+i;
                        b_h[i] = 0.f;
                     }
                     // send data from host to device: a_h to a_d 
                     cudaMemcpy(a_d, a_h, sizeof(float)*N, cudaMemcpyHostToDevice);
                     // copy data within device: a_d to b_d
                     cudaMemcpy(b_d, a_d, sizeof(float)*N, cudaMemcpyDeviceToDevice);
                     // retrieve data from device: b_d to b_h
                     cudaMemcpy(b_h, b_d, sizeof(float)*N, cudaMemcpyDeviceToHost);
                     // check result
                     for (i=0; i<N; i++)
                        assert(a_h[i] == b_h[i]);
                     // cleanup
                     free(a_h); free(b_h); 
                     cudaFree(a_d); cudaFree(b_d);
                  }
                  

                  When I build I get these errors:

                  1>------ Build started: Project: CUDASandbox, Configuration: Debug x64 ------
                  1>Linking...
                  1>moveArrays.cu.obj : error LNK2019: unresolved external symbol cudaFree referenced in function main
                  1>moveArrays.cu.obj : error LNK2019: unresolved external symbol cudaMemcpy referenced in function main
                  1>moveArrays.cu.obj : error LNK2019: unresolved external symbol cudaMalloc referenced in function main
                  1>moveArrays.cu.obj : error LNK2019: unresolved external symbol __cudaUnregisterFatBinary referenced in function __cudaUnregisterBinaryUtil
                  1>moveArrays.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterFatBinary referenced in function __sti____cudaRegisterAll_45_tmpxft_00001264_00000000_6_moveArrays_cpp1_ii_main
                  1>D:StuffProgrammingVisual Studio 2008ProjectsCUDASandboxx64DebugCUDASandbox.exe : fatal error LNK1120: 5 unresolved externals
                  1>Build log was saved at "file://d:StuffProgrammingVisual Studio 2008ProjectsCUDASandboxCUDASandboxx64DebugBuildLog.htm"
                  1>CUDASandbox - 6 error(s), 0 warning(s)
                  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
                  

                  I can compile and run the example CUDA programs that came with the SDK. I know I am missing something simple here, but what is it?

                  解决方案

                  I guess you are missing to link to the correct library. Make sure you have the CUDA library added under "Configuration Properties->Linker->Input". Refer this.

                  这篇关于初学者 CUDA 程序中未解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      <tbody id='PTvD3'></tbody>

                        <small id='PTvD3'></small><noframes id='PTvD3'>

                        <i id='PTvD3'><tr id='PTvD3'><dt id='PTvD3'><q id='PTvD3'><span id='PTvD3'><b id='PTvD3'><form id='PTvD3'><ins id='PTvD3'></ins><ul id='PTvD3'></ul><sub id='PTvD3'></sub></form><legend id='PTvD3'></legend><bdo id='PTvD3'><pre id='PTvD3'><center id='PTvD3'></center></pre></bdo></b><th id='PTvD3'></th></span></q></dt></tr></i><div id='PTvD3'><tfoot id='PTvD3'></tfoot><dl id='PTvD3'><fieldset id='PTvD3'></fieldset></dl></div>

                          <bdo id='PTvD3'></bdo><ul id='PTvD3'></ul>
                        • <legend id='PTvD3'><style id='PTvD3'><dir id='PTvD3'><q id='PTvD3'></q></dir></style></legend>
                        • <tfoot id='PTvD3'></tfoot>