CUDA 6.5:错误MSB3191无法创建目录和LNK2001未解决的外部符号 [英] CUDA 6.5: error MSB3191 Unable to create directory and LNK2001 Unresolved External symbol

查看:6145
本文介绍了CUDA 6.5:错误MSB3191无法创建目录和LNK2001未解决的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013 x64上运行CUDA 6.5。



我有一个名为MyLib的VC ++静态库项目,它与MyClient x64控制台可执行项目链接。我向这两个项目添加了CUDA 6.5构建自定义。此外,我转到配置属性 - > CUDA C / C + +,并将目标机器平台设置为64位为这两个项目,因为我想为x64平台编译它们



我添加了MyCUDACode.cpp和MyCUDACode.h文件到MyLib项目,并将其项目类型标记为CUDA C / C ++,而不是oc C / C ++编译器。 MyCUDACode.cpp有许多函数调用CUDA API函数。此外,MyCUDACode.h引用了cuda.h和cuda_runtime.h文件。



MyClient与MyLib链接。我现在得到两个编译错误:




  • 编译MyLib时出现第一个错误,表示无法创建目录

  • 其次,在链接
    MyClient和MyLib时,我得到了未解决的外部符号错误。这里是日志输出:



    ------开始:项目:MyLib,配置:版本x64 ------
    1> C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA6.5.targets(412,9):错误MSB3191:无法创建目录x64 \\ \\Release\D:\github\src\helpers\。不支持给定路径的格式。



    2> ------构建已启动:项目:MyClient,配置:版本x64 ------
    2> MyLib.lib(MyCUDACode.obj):error LNK2001:unresolved external symbol cudaGetDeviceCount



    2> MyLib.lib(MyCUDACode.obj):error LNK2001:unresolved外部符号cudaDeviceCanAccessPeer



    2> MyLib.lib(MyCUDACode.obj):error LNK2001:未解析的外部符号cudaGetDeviceProperties



    2> MyLib.lib(MyCUDACode.obj):error LNK2001:unresolved external symbol cudaSetDevice



    2> MyLib.lib符号cudaDeviceDisablePeerAccess



    2> MyLib.lib(MyCUDACode.obj):error LNK2001:未解析的外部符号cudaDeviceReset



    2> MyLib.lib(MyCUDACode.obj):error LNK2001:未解析的外部符号cudaDeviceEnablePeerAccess



    2> C:... \visual studio 2013\Projects\ Prj\x64\Release\MyClient.exe:致命错误LNK1120:7未解决的外部




发布和调试模式,但我得到相同的错误。

解决方案

我只是重现步骤来解决错误:




  • 要解决错误(临时解决方法): MSB3191:无法创建目录不支持给定路径的格式,只需将Cuda cu和cuh文件复制到Visual Studio项目夹。

  • [UPDATE] :我最近为问题找到了更好的解决方案 MSB3191:无法创建目录不支持给定路径的格式。。此修复工作不需要移动cu文件到VS项目文件夹。为此,请打开文件C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets并移动到违规行(在这种情况下为412)。此行包含以下xml部分:

     < MakeDir 
    Condition ='%(CudaCompile.ExcludedFromBuild)'! ='true'
    Directories =%(CudaCompile.DepsOutputDir)/>

    正如你所看到的,这是一个指令,告诉构建系统创建一个文件夹cuda文件正在编译。用于文件夹名称的属性为CudaCompile.DepsOutputDir。现在打开文件:C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.props。此props文件定义目标文件中使用的属性的值。现在在此props文件中搜索字词 DepsOutputDir 。只有定义和引用此关键字的XML部分是:

     <! -  Miscellaneous  - > 
    < DepsOutputFile>%(Filename)%(Extension).deps< / DepsOutputFile>
    < DepsOutputDir> $(IntDir)%(RelativeDir)< / DepsOutputDir>
    < DepsOutputPath>%(DepsOutputDir)%(DepsOutputFile)< / DepsOutputPath>



    现在,为了最终修复MSB3191问题,只需删除变量%(RelativeDir)从上面的xml部分并保存props文件(这将需要管理权限)


  • 要解决错误: LNK2001:unresolved external symbol ,请按照设置链接器部分-symbol-for-cuda-methods> post



I am running CUDA 6.5 on Visual Studio 2013 x64.

I have a VC++ static library project named MyLib which is linked with MyClient x64 console executable project. I added CUDA 6.5 build customization to both the projects. In addition, I goto Configuration Properties -> CUDA C/C++ and have set "Target Machine Platform" as 64-bit for these two projects as I want to compile them for x64 platform

I added MyCUDACode.cpp and MyCUDACode.h files to MyLib project and marked their item type as CUDA C/C++ instead oc C/C++ compiler. MyCUDACode.cpp has number of functions which call CUDA API functions. Also, MyCUDACode.h references the cuda.h and cuda_runtime.h files.

MyClient is linked with MyLib. I now get two compilation errors:

  • First error in compiling MyLib which says a Unable to create directory
  • Second, I get unresolved external symbol errors while linking MyClient with MyLib. Here is the log output:

    ------ Build started: Project: MyLib, Configuration: Release x64 ------ 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets(412,9): error MSB3191: Unable to create directory "x64\Release\D:\github\src\helpers\". The given path's format is not supported.

    2>------ Build started: Project: MyClient, Configuration: Release x64 ------ 2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaGetDeviceCount

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaDeviceCanAccessPeer

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaGetDeviceProperties

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaSetDevice

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaDeviceDisablePeerAccess

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaDeviceReset

    2>MyLib.lib(MyCUDACode.obj) : error LNK2001: unresolved external symbol cudaDeviceEnablePeerAccess

    2>C:...\visual studio 2013\Projects\Prj\x64\Release\MyClient.exe : fatal error LNK1120: 7 unresolved externals

I have tried both release and debug modes but I get same error.

解决方案

I am just reproducing the steps to resolve the errors:

  • To resolve the error(temporary workaround): MSB3191: Unable to create directory The given path's format is not supported., simply copy Cuda cu and cuh files to Visual studio project folder.
  • [UPDATE]: I recently found a better solution for the issue MSB3191: Unable to create directory The given path's format is not supported.. This fix works without need to move around the cu files to the VS project folder. For this, open the file "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets", and move to the offending line(412 in this case). This line contains following xml section:

    <MakeDir
        Condition="'%(CudaCompile.ExcludedFromBuild)' != 'true'"
        Directories="%(CudaCompile.DepsOutputDir)" />
    

    As you can see, this is a sort of directive which tells the build system to make a folder for the cuda files being compiled. The property used for folder name is CudaCompile.DepsOutputDir. Now open the file: "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.props". This props file defines values of the properties used in targets file. Now search for word DepsOutputDirin this props file. There are only XML section which defines and refers to this keyword is:

        <!-- Miscellaneous -->
        <DepsOutputFile>%(Filename)%(Extension).deps</DepsOutputFile>
        <DepsOutputDir>$(IntDir)%(RelativeDir)</DepsOutputDir>
        <DepsOutputPath>%(DepsOutputDir)%(DepsOutputFile)</DepsOutputPath> 
    

    Now, to finally fix the MSB3191 issue, simply remove the variable %(RelativeDir) from above xml section and save the props file (this would require administrative privileges)

  • To resolve the error: LNK2001: unresolved external symbol, follow the Settings for Linker section in this post

这篇关于CUDA 6.5:错误MSB3191无法创建目录和LNK2001未解决的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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