ifort compiler not found by CMake - windows

I'm using GitlabCI to perform some tests on a software library, which is supposed to provide multiplatform support. The compilation is performed by CMake, which is also supposed to detect compilers automatically. The problem is, that it's not able to detect ifort even when it's directly in the PATH.
My CMake version is 3.16.0-rc3.
.gitlab-ci.yml
win_visual_studio_2017_static_manual:
tags:
- Win
image: windows:latest
stage: build
variables:
DEPENDENCIES_LINK_TYPE: 'static'
before_script:
- 'rmdir /s /q build external_dependencies\*'
- 'call VsDevCmd.bat &&
call "C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\bin\psxevars.bat" intel64 vs2017 &&
copy /b NUL prep_success'
artifacts:
paths:
- 'prep_success'
expire_in: 5 mins
script:
- 'if not exist prep_success ( exit 1 )'
- 'where cl'
- 'where ifort'
- 'echo %cd%'
- 'echo %PATH%'
- 'call build_scripts\windows\win_VS_build_x64_release.bat'
Output
Running with gitlab-runner 11.8.0 (4745a6f3)
on win-ci1 Kh9rrkTg
Using Shell executor...
Running on WIN-CI1...
Fetching changes...
Removing prep_success
HEAD is now at 6008f3c [FIX] [WIN] Trying to fix CI on Windows
From https://code.it4i.cz/bes0030/mylib
6008f3c..58c3907 dev -> origin/dev
Checking out 58c3907d as dev...
Skipping Git submodules setup
$ rmdir /s /q build external_dependencies\*
The system cannot find the file specified.
The system cannot find the path specified.
$ call VsDevCmd.bat && call "C:\Program Files ^(x86^)\IntelSWTools\parallel_studio_xe_2019.5.068\bin\psxevars.bat" intel64 vs2017 && copy /b NUL prep_success
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Intel(R) Parallel Studio XE 2019 Update 5
Copyright (C) 2009-2019 Intel Corporation. All rights reserved.
Intel(R) Compiler 19.0 Update 5 (package 281)
1 file(s) copied.
$ if not exist prep_success ( exit 1 )
$ where cl
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86\cl.exe
$ where ifort
C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\bin\intel64\ifort.exe
$ echo %cd%
C:\Gitlab-Runner\builds\Kh9rrkTg\0\bes0030\mylib
$ echo %PATH%
C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\bin\intel64;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\bin;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\redist\intel64\compiler;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\redist\intel64_win\compiler;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:\Gitlab-Runner\builds\Kh9rrkTg\0\bes0030\mylib\..\..\intel64\libfabric\bin\utils;C:\Gitlab-Runner\builds\Kh9rrkTg\0\bes0030\mylib\..\..\intel64\libfabric\bin;C:\Gitlab-Runner\builds\Kh9rrkTg\0\bes0030\mylib\..\..\intel64\bin\release;C:\Gitlab-Runner\builds\Kh9rrkTg\0\bes0030\mylib\..\..\intel64\bin;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\ipp\..\redist\intel64\ipp;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\redist\intel64_win\mkl;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\redist\intel64_win\compiler;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\tbb\bin\..\..\redist\intel64\tbb\vc_mt;C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2019.5.068\compilers_and_libraries_2019\windows\tbb\bin\..\..\redist\intel64\tbb\vc_mt;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\\MSBuild\15.0\bin;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\;C:\Program Files\Microsoft MPI\Bin\;C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\CMake\bin;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
$ call build_scripts\windows\win_VS_build_x64_release.bat
-- Selecting Windows SDK version 10.0.17134.0 to target Windows 10.0.14393.
-- The C compiler identification is MSVC 19.15.26726.0
-- The CXX compiler identification is MSVC 19.15.26726.0
-- The Fortran compiler identification is unknown
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:2 (PROJECT):
No CMAKE_Fortran_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/Gitlab-Runner/builds/Kh9rrkTg/0/bes0030/mylib/build/CMakeFiles/CMakeOutput.log".
See also "C:/Gitlab-Runner/builds/Kh9rrkTg/0/bes0030/mylib/build/CMakeFiles/CMakeError.log".
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: ALL_BUILD.vcxproj
ERROR: Job failed: exit status 1
As you can see, where ifort provides the path to ifort compiler, also PATH variable contains the same one in the very beginning. Still, CMake doesn't seem to detect the compiler. What can be wrong here? I don't want to specify the path to the compiler explicitly, if possible.

Related

Qt Creator fails to open a CMake project due to a wrong link.exe path

I upgraded Visual Studio 2017 recently and now cannot open a CMake project in Qt Creator 4.8.2.
CMake succeeds to test the compiler when running from cmd.exe but fails in Qt Creator:
Running "C:\Program Files\CMake\bin\cmake.exe -E server "--pipe=\\.\pipe\{b2399ce2-b8c1-4992-94b7-57b65efed70f}" --experimental" in D:\checkout\mateju\integrace\util\itex\build_Qt5-Release.
Starting to parse CMake project.
The C compiler identification is MSVC 19.16.27027.1
The CXX compiler identification is MSVC 19.16.27027.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual
Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_1344c\fast"
"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"
-f CMakeFiles\cmTC_1344c.dir\build.make /nologo -L
CMakeFiles\cmTC_1344c.dir\build
Building C object CMakeFiles/cmTC_1344c.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe
#C:\Users\MATEJU~1\AppData\Local\Temp\nmEB0D.tmp
testCCompiler.c
Linking C executable cmTC_1344c.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
--intdir=CMakeFiles\cmTC_1344c.dir --manifests -- "C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\link.exe"
/nologo #CMakeFiles\cmTC_1344c.dir\objects1.rsp
#C:\Users\MATEJU~1\AppData\Local\Temp\nmEC75.tmp
LINK Pass 1 failed to run.
NMAKE : fatal error U1077: "C:\Program Files\CMake\bin\cmake.exe":
return code 0xffffffff
Stop.
NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe":
return code 0x2
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
Configuring incomplete, errors occurred!
See also "D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeOutput.log".
See also "D:/checkout/mateju/integrace/util/itex/build_Qt5-Release/CMakeFiles/CMakeError.log".
CMake Project parsing failed.
As you can see, the compiler path is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64
However, it’s looking for the linker in the path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64
So my question is: How can I update the linker path to (the only existing) 14.16.27023? Or what else should I do to continue using CMake in Qt Creator?
I’ve tried to find a corresponding option in my Qt Creator Compiler options but it claims to use the same vcvarsall.bat call which works well on command-line…
D:\build>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.8
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
D:\build>link
Microsoft (R) Incremental Linker Version 14.16.27027.1
Copyright (C) Microsoft Corporation. All rights reserved.
<and so on...>
I’ve tried the following steps without any success:
add C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64 to PATH as the answer to a similar question suggests
launch Qt Creator from cmd.exe after running vcvarsall.bat in the same window
upgrade CMake to the latest stable version (3.14.1)
install and try in Qt Creator 4.9.0-rc1
search for the string 14.10.25017
in the Windows Registry – no results
in the Qt Creator directory
no configuration files found
found .pdb and .lib files which likely only means they were built using this version of Visual Studio
in C:\Program Files (x86)\Microsoft Visual Studio – no results
in C:\Program Files (x86)\Windows Kits – no results
After several unsuccessful guesses mentioned in the question, I succeeded to open, build and run my project after I issued
Build > Clear CMake Configuration
in the menu of Qt Creator.

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.

How to run Visual Studio 2015 and 2017 on the same machine?

I installed Visual Studio Community 2015 on a server running Windows Server 2012 R2. I confirmed that the toolchain was able to build my C++ project (which uses CMake).
I then installed Visual Studio Community 2017 and confirmed that the toolchain was working as well. However, to my dismay, I soon discovered that the 2015 toolchain was no longer working. Trying to build my project resulted in the following errors:
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Nathan/Documents/repositories/qmdnsengine/build/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_614a9\fast"
"C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\BIN\amd64\nmake.exe" -f CMakeFiles\cmTC_614a9.dir\build.make
/nologo -L CMakeFiles\cmTC_614a9.dir\build
Building C object CMakeFiles/cmTC_614a9.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe
#C:\Users\Nathan\AppData\Local\Temp\2\nmB42E.tmp
testCCompiler.c
Linking C executable cmTC_614a9.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
--intdir=CMakeFiles\cmTC_614a9.dir --manifests --
C:\PROGRA~2\MICROS~1.0\VC\bin\link.exe /nologo
#CMakeFiles\cmTC_614a9.dir\objects1.rsp
#C:\Users\Nathan\AppData\Local\Temp\2\nmB577.tmp
RC Pass 1 failed to run.
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' :
return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Nathan/Documents/repositories/qmdnsengine/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Nathan/Documents/repositories/qmdnsengine/build
What does this error mean and how would I go about fixing it?

CMake Intel Fortran Compiler is not able to compile a simple program

I am using CMake to prepare a Fortran project under Windows. I have installed some inlet Fortran compiler with VC2015, and when I cmake have the following error
-- Check for working Fortran compiler: D:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/ifc.exe
-- Check for working Fortran compiler: D:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/ifc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/CMakeTestFortranCompiler.cmake:54 (message):
The Fortran compiler "D:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/ifc.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/Dev/plaf/build/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_f7da8\fast"
"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe" -f
CMakeFiles\cmTC_f7da8.dir\build.make /nologo -L
CMakeFiles\cmTC_f7da8.dir\build
Building Fortran object
CMakeFiles/cmTC_f7da8.dir/testFortranCompiler.f.obj
"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ifc.exe" -c
D:\Dev\plaf\build\CMakeFiles\CMakeTmp\testFortranCompiler.f -o
CMakeFiles\cmTC_f7da8.dir\testFortranCompiler.f.obj
usage: D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ifc.exe
[subcommand] [options...]
subcommands:
OBJ Convert an interface file into a dummy object file which can be archived into a static lib.
EMBED Embed an interface file into an existing static lib, producing a new lib.
EXTRACT Extract an embedded interface file from an existing static lib, producing the ifc.
LOCATE Find all embedded interface files and print their offset + size to stdout.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\bin\ifc.exe"' : return code '0x1'
My understanding of the error (correct me if I am wrong), is that cmake is using the compiler with the wrong flags, hence during the sample program compilation it just doesn't work.
How can I fix that ? (The error seems different from what I have seen in most other posts)
it happened by me when I used MinGW to compile. The solution is to choose "MinGW Makefiles" instead of Visual Studio in the configure of CMake

Resources