0

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.

6
  • Did you look at the very first line of the error message. You have a badly malformed path somewhere in your project set up.
    – talonmies
    Commented Dec 31, 2014 at 10:49
  • I can see that: ""x64\Release\D:\github\src\helpers\"". This particular folder "D:\github\src\helpers\" has MyCUDACode.h and MyCUDACode.cpp files. But I am not sure why the VS is using this path
    – nurabha
    Commented Dec 31, 2014 at 10:52
  • As I checked the BuildCustomizations\CUDA 6.5.targets(412,9) file, I see the following: <MakeDir Condition="'%(CudaCompile.ExcludedFromBuild)' != 'true'" Directories="%(CudaCompile.DepsOutputDir)" />
    – nurabha
    Commented Dec 31, 2014 at 10:56
  • @talonmies: I created two sample projects (console and static library) projects from scratch and added CUDA 6.5 customization to it. Now I donot get the MSB3191: Unable to create directory", but I still do get the unresolved external symbol errors
    – nurabha
    Commented Dec 31, 2014 at 11:19
  • Ok, I found how to resolve the external symbols error. Just follow this text: Settings for Linker 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..
    – nurabha
    Commented Dec 31, 2014 at 11:44

1 Answer 1

4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.