'ml' is not recognized - windows

I have Visual Studio 2015 Community installed on Win10 64-bit. Using the VS2015 x64 Native Tools Command Prompt shell, I cannot find the MASM executable, ml. I thought it was installed with VS. I found the issue when running an nmake script as part of the OpenSSL build process for Windows.
ml /nologo /Cp /coff /c /Cx /Zi /Fotmp32dll\x86cpuid.obj tmp32dll\x86cpuid.asm
'ml' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: 'ml' : return code '0x1'
Stop.
Here is my %PATH%:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\14.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\;C:\Perl64\site\bin;C:\Perl64\bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\PostgreSQL\pg95\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Mike\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\CMake\bin;C:\Users\Mike\Anaconda2;C:\Users\Mike\Anaconda2\Scripts;C:\Users\Mike\Anaconda2\Library\bin;C:\Users\Mike\AppData\Roaming\npm;C:\Users\Mike\bin
Is MASM included with VS 2015 Community, or is it a separate installable? This is the first time I've ever had to use MASM, so I'm learning a ton about the Windows build tools.

Related

Missing mspdbcore.dll when compiling arm or arm64 programs with cl.exe from VS 2017

My attempts to compile the simplest of C program to ARM, directly with cl.exe on a Win10 x86-64 environment always results in the following error:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX64\arm\cl.exe" /c 1.c
1.c
c1: fatal error C1356: unable to find mspdbcore.dll
Note that everything works fine if I target x86 code: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe" /c 1.c
I can compile and link this program just fine if doing it from within VS. Am I missing something on the PATH? It also seems that I only have two versions of mspdbcore.dll, one in Hostx64/x64 and another one in Hostx86/x86; nothing in the arm/arm64 equivalent folders.
File: 1.c:
int main(void) {
return 0;
}
Okay, it turned out the problem was connected to missing or incorrect environment variables after all...
I set up custom overrides for PATH, INCLUDE, LIB, and LIBPATH matching the values provided by the "VC++ Directories" options of a sample ARM VS project, and things are now compiling smoothly.
Edit #1: Settings I used, for VS2017: (They can be found in the "VC++ Directories" options widget I mentioned above)
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\arm;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\tools;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\ide;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
set LIB=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\lib\ARM;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\arm;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\arm
set LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\ARM;C:\Program Files (x86)\Windows Kits\10\References
Some VS directories have mspdbcore.dll, and some don't. Declaring the path in LIBPATH doesn't fix it.
For example, .\bin\Hostx64\x64\ and .\bin\Hostx86\x86\ have mspdbcore.dll, but .\bin\Hostx64\x86\ does not, so if you want to run the 32-bit compiler on a 64-bit system, use .\bin\Hostx86\x86\cl.exe, not .\bin\Hostx64\x86\cl.exe.

How do I avoid the "unresolved external symbol _mainCRTStartup" error when using the MSVC toolchain (ex: CL.EXE) from within an MSYS environment?

How do I avoid the unresolved external symbol _mainCRTStartup error when using the MSVC toolchain (ex: CL.EXE) from within an MSYS environment?
Details:
I started a "VS2013 x64 Native Tools Command Prompt" and the launched C:\msys64\msys2.exe from there.
In my MSYS session I get results like this:
user#host MSYS /c/libpostal/libpostal
$ "/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/vcvars64.bat"
user#host MSYS /c/libpostal/libpostal
$ cl "-nologo" "conftest.c" "-link" "-SUBSYSTEM:CONSOLE"
conftest.c
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
conftest.exe : fatal error LNK1120: 1 unresolved externals
user#host MSYS /c/libpostal/libpostal
$ cat conftest.c
/* confdefs.h */
#define PACKAGE_NAME "libpostal"
#define PACKAGE_TARNAME "libpostal"
#define PACKAGE_VERSION "1.0.0"
#define PACKAGE_STRING "libpostal 1.0.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define PACKAGE "libpostal"
#define VERSION "1.0.0"
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
user#host MSYS /c/libpostal/libpostal
$ echo $PATH
/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
If I try to put the same "cl" command into the "VS2013 x64 Native Tools Command Prompt", I get the expected result instead:
C:\libpostal\libpostal>cl "-nologo" "conftest.c" "-link" "-SUBSYSTEM:CONSOLE"
conftest.c
C:\libpostal\libpostal>cl "/nologo" "conftest.c" "/link" "/SUBSYSTEM:CONSOLE"
conftest.c
C:\libpostal\libpostal>conftest.exe
C:\libpostal\libpostal>echo %PATH%
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\12.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;C:\Program Files (x86)\Windows Kits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\12.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;C:\Program Files (x86)\WindowsKits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\;C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files(x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Git\cmd;C:\D\dmd2\windows\bin;C:\msys64;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\bin;C:\msys64\opt\bin
This happened while I was trying to use cccl to build a posix project (libpostal) using the MSVC toolchain so I can link it with other MSVC code. As such, any answers involving Visual Studio GUI will probably not be very helpful: I need to figure out how to make it work from within the MSYS2/MSYS64 environment.
In the MSYS example I intentionally moved /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin to the beginning of my $PATH to avoid selecting the wrong executables. I originally received the same results (exact same error message) when it was at the end of the $PATH instead.
After checking everything in agonizing detail, I found the problem:
When C:\msys64\msys2.exe is executed from the "VS2013 x64 Native Tools Command Prompt", the $PATH variable will end up containing /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin, but that is the wrong directory for 64-bit work. Instead the path should contain /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64. Once I did that substitution, cl.exe worked fine.
Running vcvars64.bat from within the MSYS environment will not fix the $PATH. The above substitution has to be done manually or from a custom startup script like ~/.bashrc.

Distutils do not call "link.exe" when using WinPython 3.6, but with WinPython 3.5 it works

I recently upgraded from Winpython version 3.5 to the respective version with python 3.6. Therefore, I have to recompile my C extensions using the new interpreter. My setup script looks as follows:
from distutils.core import setup, Extension
import numpy.distutils.misc_util
c_ext = Extension("heapoperations", ["heapoperations.c"])
setup(
ext_modules=[c_ext],
include_dirs=numpy.distutils.misc_util.get_numpy_include_dirs(),
)
The console output when using python 3.5 was
running build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
building 'heapoperations' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I"C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\site-packages\numpy\core\include" -I"C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\include" -I"C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\include" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /Tcheapoperations.c /Fobuild\temp.win-amd64-3.5\Release\heapoperations.obj
Found executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:"C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\libs" /LIBPATH:"C:\Program Files\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\PCbuild\amd64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\um\x64" /EXPORT:PyInit_heapoperations build\temp.win-amd64-3.5\Release\heapoperations.obj /OUT:D:\MyProject\heapoperations.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\heapoperations.cp35-win_amd64.lib
Found executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.exe
However, when I run the same script with python 3.6 I get
running build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
building 'heapoperations' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I"C:\Program Files\WinPython-64bit-3.6.0.1Qt5\python-3.6.0.amd64\lib\site-packages\numpy\core\include" -I"C:\Program Files\WinPython-64bit-3.6.0.1Qt5\python-3.6.0.amd64\include" -I"C:\Program Files\WinPython-64bit-3.6.0.1Qt5\python-3.6.0.amd64\include" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /Tcheapoperations.c /Fobuild\temp.win-amd64-3.6\Release\heapoperations.obj
Found executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe
That is, link.exe is not called. The result is that I do not get a .pyd file that allows me to use the code.
What could explain the behaviour? How could I make everything work under WinPython 3.6?
I am using 64bit WinPython under Windows 10 64bit.
I did a try from http://dan.iel.fm/posts/python-c-extensions/
(and _chi2.c from https://gist.github.com/douglas-larocca/099bf7460d853abb7c17)
result:
C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\notebooks>python setup.py build_ext --inplace
running build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
building '_chi2' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\lib\site-packages\numpy\core\include -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\include -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\include -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_chi2.c /Fobuild\temp.win-amd64-3.6\Release\_chi2.obj
Found executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\lib\site-packages\numpy\core\include -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\include -IC:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\include -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcchi2.c /Fobuild\temp.win-amd64-3.6\Release\chi2.obj
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\libs /LIBPATH:C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\python-3.6.0.amd64\PCbuild\amd64 /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" /EXPORT:PyInit__chi2 build\temp.win-amd64-3.6\Release\_chi2.obj build\temp.win-amd64-3.6\Release\chi2.obj /OUT:C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\notebooks\_chi2.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_chi2.cp36-win_amd64.lib
Found executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe
C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\notebooks>
test of result:
PS C:\WinPython\basedir36\buildQt5\winpython-64bit-3.6.x.2\notebooks> python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _chi2; print (_chi2.chi2(2.0, 1.0, [-1.0, 4.2, 30.6], [-1.5, 8.0, 63.0], [1.0, 1.5, 0.6]))
2.8988888888888766

nvcc fatal : Compiler 'cl.exe' in PATH different than the one specified with -ccbin

I've installed CUDA 7.5 on Windows 7-SP1 and I'm uisng Visual Studio 2013.
Unfortunately, I can't run any CUDA code. I can't even build the sample bandwidthTest. I get the following error:
C:\ProgramData\NVIDIA Corporation\CUDA
Samples\v7.5\1_Utilities\bandwidthTest>"C:\Program Files\NVIDIA GPU
Computing Toolkit\CUDA\v7.5\bin\nvcc.exe"
-gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I./ -I../../common/inc -I./
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include" --keep-dir x64\Release -maxrregcount=0
--machine 64 --compile -cudart static -Xcompiler "/wd 4819" -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -o x64/Release/bandwidthTest.cu.obj "C:\ProgramData\NVIDIA
Corporation\CUDA
Samples\v7.5\1_Utilities\bandwidthTest\bandwidthTest.cu" 1> nvcc
fatal : Compiler 'cl.exe' in PATH different than the one specified
with -ccbin 1>C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA
7.5.targets(604,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe"
-gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I./ -I../../common/inc -I./
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include" --keep-dir x64\Release -maxrregcount=0
--machine 64 --compile -cudart static -Xcompiler "/wd 4819" -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -o x64/Release/bandwidthTest.cu.obj "C:\ProgramData\NVIDIA
Corporation\CUDA
Samples\v7.5\1_Utilities\bandwidthTest\bandwidthTest.cu"" exited with
code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My environment variables are:
Path:
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\bin\x86_amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin;C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE;C:\TDM-GCC-64\bin;C:\TDM-GCC-64\x86_64-w64-mingw32;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin;C:\Program
Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\libnvvp;c:\Program Files
(x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS
Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program
Files (x86)\Hewlett-Packard\HP Performance Advisor;C:\Program
Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program
Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files
(x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files
(x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files
(x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft
SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
Server\100\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files
(x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program
Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files
(x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\Microsoft
SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL
Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL
Server\110\Tools\Binn\ManagementStudio\;C:\Program Files
(x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program
Files\R\R-3.1.3\bin\i386\;C:\Program Files (x86)\NVIDIA
Corporation\PhysX\Common
CUDA_PATH:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5
CUDA_PATH_V7_5:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5
I also changed
INCLUDES += "-I$(TOP)/include" $(SPACE)
to
INCLUDES += "-I$(TOP)/include" "-I$(TOP)/include/cudart" "-IC:/Program
Files (x86)/Microsoft Visual Studio 12.0/VC/include" $(SPACE)
in nvcc.profile.
But no luck so far!! :(
Could you please help me?!
Thanks
Problem
There are thee versions of Visual Studio compiler: for x86, for x86_64 and ARM platforms (and I heard fourth is coming soon).
The problem is most likely comes from the fact that you are compiling for a platform that is different from the compiler's platform you have in PATH.
Solution
You should never have Visual Studio's bin folders in your global PATH variable.
Remove everything related to Visual Studio from your PATH. Visual Studio IDE and CUDA tools are smart enough to find the compiler without your help (via registry entries).
If you want to run developer tools from the command line (without IDE) at the same time, use:
Visual Studio Command prompt in Start menu (which uses vcvarsall.bat script)
or use vcvarsall.bat directly (which temporarily sets up the environment for building against a platform given as a parameter)
or roll out your own script
If the above answer doesn't work for you, here's what I did with Visual Studio 2013 and CUDA 6.5 for an x64 compile.
I edited
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.props
So that
<VCBinDir Condition="'$(Platform)' == 'Win32'">$(VC_ExecutablePath_x86_x86)</VCBinDir>
<VCBinDir Condition="'$(Platform)' == 'x64'">$(VC_ExecutablePath_x64)</VCBinDir>
I have the same problem, the key cause of this problem is the name of cl.exe is duplicated. I have the BullseyeCoverage(a software which can analyze the fraction of coverage of code) installed. It have the same named cl.exe program. Then i uninstall it, the problem is gone!

How to use clang with Visual Studio and stlib?

I have installed prebuilt llvm + clang for windows 3.6.2, and Visual Studio 2015. Now in VS 2015, you can create projects and set compiler to clang. It seems the installation of clang has registered the compilers to the settings. Everything else works fine, except I cannot use and standard libraries.
The compiler setting for clang is LLVM-vs2014 under properties->general->platform tools
For instance, when compiling this code
#include <iostream>
int main(int argc, char ** argv) {
return 0; }
if I delete the #include line, everything works fine.
any idea?
The output message from VS is:
1>------ Build started: Project: TT, Configuration: Debug Win32 ------
1>clang-cl.exe : warning : argument unused during compilation: '/ZI'
1>clang-cl.exe : warning : argument unused during compilation: '/Gm'
1>clang-cl.exe : warning : argument unused during compilation: '/GS'
1>clang-cl.exe : warning : argument unused during compilation: '/fp:precise'
1>clang-cl.exe : warning : argument unused during compilation: '/FdDebug\vc140.pdb'
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1
> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath:656:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtgmath.h:8:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(231,22): error : use of undeclared identifier 'char16_t'
1> struct _Is_integral<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(237,22): error : use of undeclared identifier 'char32_t'
1> struct _Is_integral<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits:6:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(408,14): error : use of undeclared identifier 'char16_t'
1> struct hash<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(414,14): error : use of undeclared identifier 'char32_t'
1> struct hash<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:8:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(615,33): error : use of undeclared identifier 'char16_t'
1> template<> class numeric_limits<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(905,33): error : use of undeclared identifier 'char32_t'
1> template<> class numeric_limits<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(267,21): error : use of undeclared identifier 'char16_t'
1> struct char_traits<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(276,21): error : use of undeclared identifier 'char32_t'
1> struct char_traits<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,22): error : use of undeclared identifier 'char16_t'
1> typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,53): error : expected unqualified-id
1> typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,22): error : use of undeclared identifier 'char32_t'
1> typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,53): error : expected unqualified-id
1> typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1004,30): error : use of undeclared identifier 'char16_t'
1> class _CRTIMP2_PURE codecvt<char16_t, char, _Mbstatet>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1328,30): error : use of undeclared identifier 'char32_t'
1> class _CRTIMP2_PURE codecvt<char32_t, char, _Mbstatet>
1> ^
1> 14 errors generated.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Clang 3.6 doesn't support the C++11 keywords char16_t and char32_t in Microsoft mode (see the source). However good news, 3.7 does and will be released in three weeks (August 21) according to the LLVM website. In the meanwhile you could install a 3.7 release candidate or a snapshot build.

Resources