2020: nvcc fatal : Cannot find compiler 'cl.exe' in PATH - visual-studio

I'm trying to run StyleGan2 by Nvidia. I have created a new enviroment, I failed this check mandated in the readme file provided.
In particular, when I run it, I get the error you see in the title of the question. I looked it up, and the solution ostensibly is to add this path to env vars
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
I'm trying to do that, but I don't have bin in my VC folder! I only have include and lib, brand new installation of visual studio.

Thanks to #talonmies, the solution is as follows:
Firstly, c++ package doesn't come by default with a clean new installation of VS, you need to select the package.
Secondly, it seems that now the path for cl.exe is here
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64

In my case the full error message was:
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
...
No CMAKE_CUDA_COMPILER could be found.
Tell CMake where to find the compiler by setting either the
environment variable "CUDACXX" or the CMake cache entry
CMAKE_CUDA_COMPILER to the full path to the compiler, or to the
compiler name if it is in the PATH.
So I had to do:
export CUDACXX="/mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe"
and it worked.

Related

Can't find VisualStudio linker LINK.EXE

I'm following the openCl documentation provided by Altera to setup an FPGA board and run an example on it. So far I have installed the SDK and followed the instructions but when I get to the step where I have to compile the kernel, I get the following error:
Error: aoc: Can't find VisualStudio linker LINK.EXE.
Either use Visual Studio x64 Command Prompt or run %ALTERAOCLSDKROOT%\init_opencl.bat to setup your environment.
So I tried running the init_opencl.bat script but I get the following message:
AOCL_BOARD_PACKAGE_ROOT path is not set in environment
Setting to default s5_ref board.
If you want to target another board, do
set AOCL_BOARD_PACKAGE_ROOT=board_pkg_dir and re-run this script
VisualStudio's link.exe is not on the path. Guessing its location.
Cannot find VisualStudio installation by looking at the environment.
If VisualStudio is installed, use VisualStudio Command Prompt to set all
required environment variables.
Here is a link to the documentation I am trying to follow:
https://documentation.altera.com/#/00016207-AA$NT00067143
I also tried adding link.exe to the environment variables path but that had no luck. (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe).

CMake and Visual Studio with not default installation folder

I am trying to build something using CMake and VS 2012. The problem is I have my VS installation on D:\Pliki programów (x86)\Microsoft Visual Studio 11.0. I have no free space on my C drive.
CMake have problem with finding my VS. I tried to specify VS compiler cl.exe but it was asking for dll in the same folder anyway. I also tried to use specified toolchaing with vcvarsall.bat. But I am not sure if I am doing those things right.
I guess that I need to add VS location to CMake, but how? I tried setting PATH but it did not work.
And searching about that problem is difficult, all search engines think that I want to change installation path for my program that I want to build.
UPDATE
I've added variable_watch(CMAKE_MAKE_PROGRAM).
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using UNKNOWN_READ_ACCESS with
value .
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using MODIFIED_ACCESS with value
C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
In output file:
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
Is CMake looking for libs in VS 11 installation folder? The thing is that VS installer put libs in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64.
For cases like this (and similar), I keep a VCEnvCmd.bat in my source trees:
call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 & %*
Executing that .bat without parameters will find and run vcvarsall.bat, setting up the environment for the amd64 target in the current shell (which you could change or parameterize according to your needs, like the version number embedded in that environment variable).
The nice trick is, for those Nightly / Continuous builds, you can use the .bat as a "prefix" for setting up the environment, e.g. in the task manager:
VCEnvCmd.bat ctest -S CTestScript.cmake,Nightly
The advantage is that you use what MSVC already gives you (the VS...COMNTOOLS variable), without having to clutter your environment further with persistent changes to PATH etc.

How to specify a windows directory that has spaces in it in .theanorc

I need to use the --compiler-bindir flag to specify directory that contains cl.exe to nvcc. If I specify it like this:
[nvcc]
flags = --compiler-bindir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
I get error while importing theano in python that complains about spaces. What is the proper way to specify this directory in .theanorc? Note that I do not want to edit my nvcc.profile.
Try the following, if you haven't yet, it seems to work for other people:
[nvcc]
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
See also this long Stackoverflow guide about installing Theano on Windows.

Running vcvars32.bat before compiling in Code::Blocks?

I've installed Visual Studio C++ Express 2012 and want to use it's compiler with Code::Blocks. Starting cl.exe does not work (missing mspdb100.dll) until I run vcvars32.bat, but that does only hold on for the current session in the Command-line. The same applies to compiling with Code::Blocks.
How can I make it run the vcvars32.bat before compiling?
Workaround
That workaround is actually not what I was looking for, but it works, and that is important. Instead of letting Code::Blocks running cl.exe directly, I've set-up a simple batch-script that runs vcvars32.bat before running the actual compiler.
REM File: cl.bat
call vcvars32.bat
call cl.exe %1 %*
In the project properties, you have a section Build events. You can add vcvars32.bat to the pre-build event.
To run the .bat before compiling in Code Blocks(16.01), go to the project build options and its under the "pre/post build steps" tab. This tab only appears in the project settings, not the compiler settings.
However, adding "vcvars32.bat" (or "vcvars64.bat") to the pre build steps didn't fix the error for me.
I found the directory where the library is and added it to the linker search directories. This gave errors about further missing libraries. I added the following paths to my linker settings. These will almost certainly be different for you. I'm installed MSVS 2017 community edition. For some reason known only to Microsoft, the necessary libraries are installed on two different drives.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64
Note that the .bat script is no longer necessary if you add these paths by hand.

Building Qt for Visual Studio 2010 - cannot open file 'qtmaind.lib'

I'm trying to start a C++ Qt application and have it run and compile in Visual Studio 2010.
Doing some googling, I found that there was a Visual Studio Qt Add-in, and so I installed this. I already had a MinGW Qt binary installed, and when this did not work, I found that you have to compile the source for Visual Studio 2010 (the VS 2008 binary will cause deployment issues).
Using this as a guide: How to build Qt for Visual Studio 2010, I compiled the open source version, and added it to the PATH, along with a QTDIR env variable. Hoping that I got it finally working, I created a "Qt Application" using the New Project Wizard in Visual Studio 2010. Once I finished, I tried to build the program, only to see the following error:
1>LINK : fatal error LNK1104: cannot open file 'qtmaind.lib'
I looked in the C:\QT\lib folder, and found that I only have a qtmaind.prl, but no clue as to why there is no qtmaind.lib.
I am able to echo the QMAKESPEC environmental variable to get a 'win32-msvc2010' output.
I've tried several different combinations of flags for the configure step, including the one in the link, and even tried manually setting the -platform flag.
If anyone can offer any help, it would be greatly appreciated! :D
Just ran across this same problem. I changed the "-release" flag from the linked guide to "-debug-and-release", and then it built the qtmaind.lib library (presumably, that "d" suffix stands for debug).
I encountered this issue when running a project whose settings were hardcoded for a particular machine setup.
I could see that the vcxproj file had something like:
C:\Qt\4.8.1\libqtmaind.lib
I could not find this lib file in my machine. I replaced the line by:
C:\Qt\4.7.3\lib\Qtmaind.lib
It looks like the names of library files are different across Qt versions.Or, maybe the library files were renamed.
Also, the 'd' denoted debug. If you cannot find any lib file post-fixed by 'd', it is likely that you did not 'make' a debug version of Qt.
You can cross check this by opening the .Sln file created by configure. Mine was named Projects.sln. You can open this in notepad and see if win32-debug configurations are present.
This might be a QMAKESPEC issue. Try setting your QMAKESPEC environment variable to
win32-msvc2010
and rebuild Qt like that. This should give you .lib files in your Qt folder
in QT 5.3 with vs 2013
in properties -> linker -> input
remove ANY path for qt libraries such qtmaind.lib
this is known BUG

Resources