Command line build w/Visual Studio (C++) and PGI (pgfortran)

I saw the topic regarding mixed Intel-PGI compilers at www.pgroup.com/userforum/viewtopic.php?t=6283

My question is whether it’s possible to use Visual Studio 2017 Community Edition (for C++) and PGI Community Edition (for Fortran90) on Windows 64 using the command line to build with cmake (3.13.1) and nmake.

Source code is a mix of C++ (no OpenMP) and Fortran90 (with OpenMP), where the C++ code calls the Fortran90 code.

I’m working inside the command window “x64 Native Tools Command Prompt for VS 2017”, so perhaps it’s no surprise CMake can find the VS2017 C++ compiler with:

set (CMAKE_CXX_COMPILER “C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe”)

(Aside: CMake uses the forward slash even on Windows)…but CMake cannot identify the Fortran compiler (CMake output is “Fortran compiler identification is unknown”). Here is my setting in CMakeLists.txt:

set (CMAKE_Fortran_COMPILER “C:/Program Files/PGI/win64/18.10/bin/pgfortran.exe”)

The test compile CMake attempts with the Fortran compiler fails.

The same outcome/error occurs if I use the PGI 18.10 command window, that is, cl.exe is found/works and pgfortran is unknown/broken.

Thanks for any guidance possible,
Andy

Hi rag,

What you’re asking for should be possible. Typically if Make/Cmake can’t find the compiler, make sure it is in the Path environment variable. You can set this explicitly but it should be set automatically if you are using the pgi.bat in C:\Program Files\PGI\win64\18.10. If you type which pgfortran inside the command window it should print a full path to it.

The log file might have some more clues. There should be a CMakeError.log somewhere in your project (check inside CMakeFiles/). Feel free to post it here or email it to trs@pgroup.com.

Appreciate the guidance. In the VS2017 command window, before ‘pgi.bat’ no surprise that ‘which pgfortan’ comes back negative…but after ‘pgi.bat’ it displays the correct pgfortan.exe and path.

Here is the CMakeError.log


Compiling the Fortran compiler identification source file “CMakeFortranCompilerId.F” failed.
Compiler: C:/Program Files/PGI/win64/18.10/bin/pgfortran.exe
Build flags:
Id flags:

The output was:
1

Microsoft Visual Studio 2017 Version 15.0.28307.145.
Copyright (C) Microsoft Corp. All rights reserved.

The license for Visual Studio expires in 26 days.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.
1>Error: The operation could not be completed. Unspecified error
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Compiling the Fortran compiler identification source file “CMakeFortranCompilerId.F” failed.
Compiler: C:/Program Files/PGI/win64/18.10/bin/pgfortran.exe
Build flags:
Id flags:

The output was:
1

Microsoft Visual Studio 2017 Version 15.0.28307.145.
Copyright (C) Microsoft Corp. All rights reserved.

The license for Visual Studio expires in 26 days.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.

Package ‘IFLangServicePackage’ failed to load.
1>Error: The operation could not be completed. Unspecified error
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Checking whether the Fortran compiler is Compaq using “-what” did not match “Compaq Visual Fortran”:
pgfortran-Error-Unknown switch: -what
Checking whether the Fortran compiler is NAG using “-V” did not match “NAG Fortran Compiler”:

pgfortran 18.10-0 64-bit target on x86-64 Windows -tp haswell
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
Checking whether the Fortran compiler is Compaq using “-what” did not match “Compaq Visual Fortran”:
pgfortran-Error-Unknown switch: -what
Checking whether the Fortran compiler is NAG using “-V” did not match “NAG Fortran Compiler”:

pgfortran 18.10-0 64-bit target on x86-64 Windows -tp haswell
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
Determining if the Fortran compiler works failed with the following output:
Change Dir: C:/Users/goodwin/ELAMmodel/ELAMsourceCode/build/CMakeFiles/CMakeTmp

Run Build Command:“C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/devenv.com” “CMAKE_TRY_COMPILE.sln” “/build” “Debug” “/project” “cmTC_5b3c8”


Microsoft Visual Studio 2017 Version 15.0.28307.145.

Copyright (C) Microsoft Corp. All rights reserved.



The license for Visual Studio expires in 26 days.



Package ‘IFLangServicePackage’ failed to load.


Package ‘IFLangServicePackage’ failed to load.


Package ‘IFLangServicePackage’ failed to load.


Package ‘IFLangServicePackage’ failed to load.


Package ‘IFLangServicePackage’ failed to load.
1>Error: The operation could not be completed. Unspecified error

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I made progress, and thought I was home free…but ran into an issue at the very end (link step). On Windows 10, when linking output from Visual Studio 2017’s cl.exe and PGI’s pgfortran.exe through the command prompt, I get the following error:

/MANIFESTFILE:elam.dll.manifest" failed (exit code 1120)
error LNK2019: unresolved external symbol … referenced in function …

I started with the Visual Studio 2017 command prompt window (x64 Native Tools Command Prompt for VS 2017), then run pgi.bat, then run cmake (seemingly successful), then nmake (seemingly successful until the near-final link). It doesn’t seem to be (in my limited knowledge on this issue) related to the problem(s) here:

I tried some of the solutions here with no resolution:

I’m assuming that I’m missing an environment variable, a path, and/or a library for the link. The only thing in CMakeError.log is:

The Fortran compiler identification could not be found in “C:/Users/goodwin/ELAMmodel/ELAMsourceCode/buildELAM_Win10_compilersVS2017andPGI/CMakeFiles/3.13.2/CompilerIdFortran/CMakeFortranCompilerId.dwf”

but screen output during nmake makes me think this problem was resolved later in the build process. The screen output is long, so I’ll email it to you at trs@pgroup.com.

Thanks, Andy