Cannot load a sample CUDA project: link: unknown option -- L

已完成

Hello,

I've created a sample CUDA project in CLion, but it fails to link. I have Windows Kits and CUDA SDK installed.

"C:\Program Files\JetBrains\CLion 2022.1.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.1.2/bin/ninja/win/ninja.exe" -G Ninja -S C:\Users\Jacek\CLionProjects\neural -B C:\Users\Jacek\CLionProjects\neural\cmake-build-debug
-- The CUDA compiler identification is NVIDIA 11.0.167
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - failed
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe - broken
CMake Error at C:/Program Files/JetBrains/CLion 2022.1.2/bin/cmake/win/share/cmake-3.22/Modules/CMakeTestCUDACompiler.cmake:56 (message):
  The CUDA compiler

    "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/Jacek/CLionProjects/neural/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):C:/Program Files/JetBrains/CLion 2022.1.2/bin/ninja/win/ninja.exe cmTC_77159 && [1/2] Building CUDA object CMakeFiles\cmTC_77159.dir\main.cu.obj
    main.cu
    [2/2] Linking CUDA executable cmTC_77159.exe
    FAILED: cmTC_77159.exe 
    cmd.exe /C "cd . && "C:\Program Files\JetBrains\CLion 2022.1.2\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_77159.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\Git\usr\bin\link.exe /nologo CMakeFiles\cmTC_77159.dir\main.cu.obj  /out:cmTC_77159.exe /implib:cmTC_77159.lib /pdb:cmTC_77159.pdb /version:0.0 /debug /INCREMENTAL  cudadevrt.lib  cudart_static.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/lib/x64"  && cd ."
    LINK Pass 1: command "C:\PROGRA~1\Git\usr\bin\link.exe /nologo CMakeFiles\cmTC_77159.dir\main.cu.obj /out:cmTC_77159.exe /implib:cmTC_77159.lib /pdb:cmTC_77159.pdb /version:0.0 /debug /INCREMENTAL cudadevrt.lib cudart_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/lib/x64 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_77159.dir/intermediate.manifest CMakeFiles\cmTC_77159.dir/manifest.res" failed (exit code 1) with the following output:
    link: unknown option -- L
    Try '/usr/bin/link --help' for more information.
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!

I have a fresh installation of CLion Trial version and just wanted to make a new CUDA project.

I'm pretty sure that 

C:\PROGRA~1\Git\usr\bin\link.exe

is not what should be called here. I've ran "where link" in cmd and got this:

C:\Users\Jacek>where link
C:\Program Files\Git\usr\bin\link.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x64\link.exe

Anyway, all I did is I created a new empty CUDA project.

0

I've resolved the above error by removing Git from PATH environment variable. Now I got another error:

    LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx86\x64\link.exe /nologo CMakeFiles\cmTC_0d2cf.dir\main.cu.obj /out:cmTC_0d2cf.exe /implib:cmTC_0d2cf.lib /pdb:cmTC_0d2cf.pdb /version:0.0 /debug /INCREMENTAL cudadevrt.lib cudart_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/lib/x64 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_0d2cf.dir/intermediate.manifest CMakeFiles\cmTC_0d2cf.dir/manifest.res" failed (exit code 1104) with the following output:
    LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
0

I've resolved the above error by changing toolchain to Visual Studio AND setting target architecture from auto detected to amd64

0

请先登录再写评论。