Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29278 Discussions

Switch default ifortvars Visual Studio version

swegner
Beginner
1,173 Views
Hi,

I am building a commandline build script for our project which uses Intel Visual Fortan 9.1 inside of Visual Studio. Currently we support Visual Studio .NET 2003 and Visual Studio 2005 for building within the IDE. I would like to create similar builds from the commandline using the "devenv" command.

To do so, we first call "%ifort_compiler91%IA32Binifortvars.bat" to setup paths for the tools. However, the ifortvars batch file calls the vcvars32.bat script for the default Visual Studio version it was installed with (VS2005 for me). Is there any way to choose the version of Visual Studio it sets up? Note that we plan on distributing this build script, so I'm looking for a solution that is relatively portable.

Thanks,
Scott Wegner
0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,173 Views
A couple of different things here. When you install Intel Fortran 9.1, it asks you which version if VS, if you have more than one, you want command line integration for. Later versions don't ask but you can do a "Change" on the installed version to change it.

Second, when you invoke devenv.exe, nothing you do by calling ifortvars.bat matters because all of the include, library and executable paths are taken from the registry for the version of VS you selected. Unless.. unless you also add /useenv to the invocation of devenv.exe, in which case the command session's environment will be used.

So if you are invoking the appropriate devenv.exe, you should automatically get that version of VS. Since you're using 9.1, you can't even select the compiler to use. Is there really a problem? Perhaps all you need to do is run the "right" devenv.exe by specifying the full path.
0 Kudos
swegner
Beginner
1,173 Views
Hi Steve,

Thanks for the quick reply. I guess one thing I forgot to mention is that we *would* like to use the "/useenv" switch in our build script. :)

If the default version of Visual Studio is chosen at install-time, then I we really can't depend on ifortvars.bat for a default behavior in any portable script, can we?

Initially I was thinking about calling ifortvars.bat, and then subsequently calling vcvars32.bat for the correct version of Visual Studio. This would get us the correct version of devenv, as the vcvars32.bat version will show up first in the path. However, we will also have both versions of Visual Studio INSTALL and LIB paths in their respective variables, which seems pretty dangerous when using /useenv.

The last thing I can think of is to run the correct vcvars32 batch, then parse through the ifortvars file, and run all of the lines *except* the one that calls vcvars32. However, this is a pretty dirty hack, so I'd like to avoid it. Any other ideas?

Scott
0 Kudos
Steven_L_Intel1
Employee
1,173 Views
Actually, calling vcvars32 a second time should work ok. You will also need to deal with ifort.cfg, which is in the same folder as ifortvars.bat. This includes a switch such as /Qvc8 that tells the compiler which version of VS it should be compatible with. The only thing I know of that this affects is the default of /ML vs. /MT (/ML or /libs:static and not /thread is not supported with VS2005). Since you're invoking the compiler from VS, the only issue is that you may get a warning that a different value was overridden - that is harmless and can be ignored.
0 Kudos
swegner
Beginner
1,173 Views
Hmm, interesting. I'm still a little weary about having both Visual Studio paths in the LIB variable when using /useenv switch-- I believe Visual Studio .NET and 2005 target different versions of the .NET framework, and I don't want to accidentally link with the wrong runtime libraries.

For now, I'm simply adding a clause to the script to only support using the default Visual Studio version as per the Intel Visual Fortran installed choice. For anyone following along, my batch script uses the following function:

rem Make sure that the version of Visual Studio we're using is the same as
rem the version that has been set up with the Intel Visual Fortran.
rem This function returns 0 if everything is OK, and 1 otherwise.
:check-ifort-vs

setlocal
 if defined use_vnet_2003 (
 call "%ifort_compiler91%IA32Binifortvars.bat" | findstr ".NET 2003" > nul
 ) else (
 call "%ifort_compiler91%IA32Binifortvars.bat" | findstr "2005" > nul
 )
 endlocal && exit /b %errorlevel%

This will work on versions of Windows XP as long as Intel Fortran 9.1 is installed and IFORT_COMPILER91 is defined in the environment. It should also work on Windows Vista, although untested.

0 Kudos
Steven_L_Intel1
Employee
1,173 Views
Well, on Vista, neither VS.NET 2003 nor ifort 9.1 are supported.
0 Kudos
Reply