- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
right now, I have Visual Studio 2017 with two fortran version installed, 17 and 19.
I can change between any version through the UI with no problem, but I need to select the version through the console as I am using devenv to build.
As far as I know, you can change the fortran version by executing the compilervars.bat of the version you want to be selected, and then the devenv command, but this seems to not work for me.
The command is something along with
"compilervars.bat intel64 vs2017 && devenv project /Rebuild"
For example when trying to build with fortran 19, at first shows the right version as
"Intel(R) Compiler 19.0 Update 8 (package 324)"
but when the build starts, vcvarsall.bat is called and then the version is changed showing
"Compiling with Intel(R) Visual Fortran Compiler 17.0.7.272 [Intel(R) 64]..."
Am I missing something here? Is vcvarsall.bar overwritting the envoriment set by compilervars.bat, if so, how can avoid this?
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding /useenv to your devenv command. This tells VS to use the current environment variables rather than what's in Tools > Options.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well Devenv runs "Visual Studio" so I would presume it will build with whatever the default fortran version is configured within VS irrespective of the environment in the command window. That would be my guess. If you type IFORT in the cmd window that will run the version associated with the ....vars.bat you ran because that uses the PATH. I think VS has it's own configuration .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding /useenv to your devenv command. This tells VS to use the current environment variables rather than what's in Tools > Options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your reply.
By adding /useenv I got this error
The Fortran compiler (ifort.exe) cannot be found.
I thought the compilervars.bat batch file would set the needed enviroment variables to use the correct ifort version. Is this not correct?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the CMD windows after running compilervars.bat does the command IFORT work? I expect that is will showing that IFORT is in the path but that deveev is not using PATH for that. I guess we need to understand what it is using. My env had IFORT_COMPILER21= and also to older versions set. Maybe as a test delete all IFORT_COMPILERxx= except the one you want or maybe set the path of the LATEST to the path of the one you actually want. That might give some insight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply andrew_4619
the command ifort works after running compilervars.bat but it stops working after executing the devenv /useenv command.
I set also IFORT_COMPILER19 and IFORT_COMPILER17 with the same value so it runs the same fortran version, but this also does not work and throws the "The Fortran compiler (ifort.exe) cannot be found" error.
It seems like devenv /useenv clears all the enviroment variables set before. I have also added the fortran path to the PATH enviroment variable and also this does not work. (I set all those enviroment variables from the same console before running devenv as after testing I need to have those commands automated)
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@office_js wrote:
It seems like devenv /useenv clears all the enviroment variables set before. I have also added the fortran path to the PATH enviroment variable and also this does not work. (I set all those enviroment variables from the same console before running devenv as after testing I need to have those commands automated)
That's not the case - I tried it. Please show a complete log of a command prompt session showing the problem.
devenv /useenv doesn't "clear" anything - it simply uses the PATH/LIB/INCLUDE environment variables that are current rather than those from Tools > Options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve_Lionel for your reply.
This is what I get when trying to set Path and Ifort compiler
"%ProgramFiles(x86)%/IntelSWTools/compilers_and_libraries_2017.7.272/windows/bin/compilervars.bat" intel64 vs2017 && set IFORT_COMPILER19=%ProgramFiles(x86)%/IntelSWTools/compilers_and_libraries_2017.7.272/windows && set PATH=%PATH%;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.7.272\windows\bin\intel64 && devenv /useenv project.sln /Rebuild "Release|x64"
Intel(R) MPI Library 2017 Update 4 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright (C) 2007-2017 Intel Corporation. All rights reserved.
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
Intel(R) Compiler 17.0 Update 7 (package 272)
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.40
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
'devenv' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。
And this when I only set ifort compiler (I cant paste all the log for company privacy policy)
"%ProgramFiles(x86)%/IntelSWTools/compilers_and_libraries_2017.7.272/windows/bin/compilervars.bat" intel64 vs2017 && set IFORT_COMPILER19=%ProgramFiles(x86)%/IntelSWTools/compilers_and_libraries_2017.7.272/windows && devenv /useenv project.sln /Rebuild "Release|x64"
Intel(R) MPI Library 2017 Update 4 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright (C) 2007-2017 Intel Corporation. All rights reserved.
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
Intel(R) Compiler 17.0 Update 7 (package 272)
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.40
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
1>------ Rebuild All started: Project: project, Configuration: Release x64 ------
1>Deleting intermediate files and output files for project 'jheat_lib', configuration 'Release|x64'.
1>path: warning: TargetPath(path) does not match the Library's OutputFile property value (path). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>The Fortran compiler (ifort.exe) cannot be found.
And I have also run commands with some differences (setting as well IFORT_COMPILER17) but same results.
I guess the main issue is when setting path which is when devenv stops working, but after setting path I have checked the environment variable to see that values are ok.
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you make a shortcut and use
C:\Windows\System32\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.8.275\windows\bin\ipsxe-comp-vars.bat" intel64 vs2017"
for the target, and with the "start in directory" set to something convenient for source files, what happens when you try to compile?
Based on other comments seen here, "compilers_and_libraries_2017.8.275" probably should be changed to appropriate version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I find the commands you are using very confusing. You should not be separately setting PATH or IFORT_COMPILER19 after calling the 2017 BAT file. The BAT file will set up PATH correctly.
However... I did a test just now starting the Parallel Studio XE 2020 command environment, then doing devenv /useenv, and found that Visual Studio ignored the command environment and used the default. I remember seeing this problem several years ago - it looks as if it has returned.
You can select an older installed compiler version in Visual Studio - see How to Select Intel® Fortran Compiler and Compiler Version in...
Then when you use devenv from the command line to do a build it will use that compiler.
I will have to do some more experiments here that may lead to a bug report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I did some more tests. The bad news is that the earlier bug I filed (ticket 02957458) was against the 17.0/2017 version, so if that's the version you have, /USEENV will not work at all. Indeed, the symptom you describe (ifort.exe not found) is exactly what I saw when I reported it in 2017. It did not get fixed until late 2020.
It works in the current release.
Intel(R) MPI Library 2019 Update 9 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright 2007-2020 Intel Corporation.
Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
Intel(R) Compiler 19.1 Update 3 (package 311)
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.8
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Program Files (x86)\IntelSWTools>d:
D:\>cd projects
D:\Projects>ifort -c t.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.311 Build 20201010_000000
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
D:\Projects>cd console6
D:\Projects\Console6>devenv console6.sln /useenv /rebuild "Debug|X64"
Rebuild started...
1>------ Rebuild All started: Project: Console6, Configuration: Debug x64 ------
1>Deleting intermediate files and output files for project 'Console6', configuration 'Debug|x64'.
1>Compiling with "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.4.311\windows\bin\intel64\ifort.exe"...
1>Console6.f90
1>Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.311 Build 20201010_000000
1>Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
1>Linking...
1>Embedding manifest...
1>
1>Build log written to "file://D:\Projects\Console6\x64\Debug\BuildLog.htm"
1>Console6 - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
D:\Projects\Console6>
Here's what I get if I don't use /useenv:
D:\Projects\Console6>devenv console6.sln /rebuild "Debug|X64"
Rebuild started...
1>------ Rebuild All started: Project: Console6, Configuration: Debug x64 ------
1>Deleting intermediate files and output files for project 'Console6', configuration 'Debug|x64'.
1>Compiling with Intelr Fortran Compiler Classic 2021.5.0 [Intel(R) 64]...
1>Console6.f90
1>Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.5.0 Build 20211109_000000
1>Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
1>Linking...
1>Embedding manifest...
1>
1>Build log written to "file://D:\Projects\Console6\x64\Debug\BuildLog.htm"
1>Console6 - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply Steve_Lionel
Do you know if this problem also occurs in Fortran 2019?
I have tried to uninstall Fortran 2017 and run the same command only with 2019 version installed to make sure it runs but I have the same problem when adding /useenv
"%ProgramFiles(x86)%/IntelSWTools/compilers_and_libraries_2019.6.324/windows/bin/compilervars.bat" intel64 vs2017 && devenv project.sln /Rebuild "Release|x64" /useenv
Intel(R) MPI Library 2019 Update 7 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright 2007-2020 Intel Corporation.
Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
Intel(R) Compiler 19.0 Update 8 (package 324)
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.40
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
1>------ Rebuild All started: Project: project, Configuration: Release x64 ------
1>Deleting intermediate files and output files for project 'project', configuration 'Release|x64'.
1>project: warning: TargetPath(poject.lib) does not match the Library's OutputFile property value (project.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>The Fortran compiler (ifort.exe) cannot be found.
1>
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you upgrade to VS 2022 and the latest ONEAPI and use the ifx compiler you will notice a nice difference.
Just an observation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem was not fixed until version 2021.2, if I recall correctly.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page