Configuring Visual Studio for Mixed-Language Applications

Introduction

If your application mixes Fortran with C or C++ and the main program is not in Fortran, you must configure Microsoft Visual Studio* to search Fortran libraries.  This article describes the process for Microsoft Visual Studio 2013, 2012, 2010, 2008, 2005 and 2003, and applies to the following products:

  • Intel® Parallel Studio XE 2015 supports Microsoft Visual Studio 2013, 2012 and 2010. In the text below, substitute 15 where [vv] is shown.
  • Intel® Visual Fortran Composer XE 2013 SP1 supports Microsoft Visual Studio 2013, 2012, 2010 and 2008. In the text below, substitute 14 where [vv] is shown.
  • Intel® Visual Fortran Composer XE 2013 supports Microsoft Visual Studio 2012, 2010 and 2008. In the text below, substitute 13 where [vv] is shown.
  • Intel® Visual Fortran Composer XE 2011 supports Microsoft Visual Studio 2010, 2008 and 2005. In the text below, substitute 12 where [vv] is shown.
  • Intel® Visual Fortran Compiler Professional Edition 11.1 supports Microsoft Visual Studio 2008, 2005 and 2003. In the text below, substitute 11 where [vv] is shown.

Configuring Microsoft Visual Studio 2003, 2005 or 2008

This configuration needs to be done one time only per install of Microsoft Visual Studio.

Open Microsoft Visual Studio.  Select Tools > Options. In the left pane, expand Projects and Solutions,  click on VC++ Directories. (Visual Studio .NET 2003 uses "Projects" instead of "Projects and Solutions") and then select "Library Files" for "Show directories for".

Setting library list in VS2008

Click on the New Line button (to the right of the "check mark" button) and enter the following new line if you are using Intel Visual Fortran XE 2011 or newer:

$(IFORT_COMPILER[vv])compiler\lib\ia32

(remember to substitute for [vv] as described above)

or the following new line if you are using Intel Visual Fortran 11.x:

$(IFORT_COMPILER11)lib\ia32

Click OK.

If you will be developing for the Intel 64 architecture, repeat the above steps, using the Platform dropdown to select "x64" (Intel 64) . When entering the path, use "intel64" instead of "ia32". Note that Microsoft Visual Studio 2003 does not support the x64 platform. If you do not see x64 as an available platform, see the Fortran Release Notes for instructions on how to configure Microsoft Visual Studio for 64-bit development.

Additional Notes

If you are using Visual Studio 2005, you must install Visual Studio 2005 Service Pack 1, otherwise your Fortran project will not be found when linking the C/C++ project.

Configuring Microsoft Visual Studio 2013, 2012 or 2010

NOTE: In Microsoft Visual Studio 2010 and later, a C++ project will not link in a non-C++ dependent project library. If you are using a C/C++ main program with a Fortran static or dynamic library as a dependent project, you must explicitly provide the path to the Fortran library, (the .lib export library in the case of a DLL project), in the C/C++ project's Linker > Additional Dependencies property, or as a "source file" in the project.

NOTE: In Microsoft Visual Studio 2010 and later, a Fortran project will not link in a C++ DLL dependent project.  A C++ static library dependent project will be linked in. If your Fortran project has a dependent C/C++ DLL project, you must explicitly provide the path to the C++ project's DLL export library (.lib) in the Fortran project's Linker > Additional Dependencies property, or as a "source file" in the project.

  1. In Visual Studio, with a solution open that contains a C++ project, select View > Property Manager. If you do not see Property Manager under the View menu, you will find it under View > Additional Windows. The Property Manager window will appear. Note that this is not Properties Window or Properties Pages.
  2. Click on the triangles or + signs to expand the property tree under the Debug|Win32 configuration. See the image below.
  3. Double click on Microsoft.Cpp.Win32.user
  4. Select VC++ Directories
  5. Click in the field to the right of "Library Directories"
  6. Click the triangle that appears to the right and select <Edit...>
  7. Click the New Line button or press Ctrl-Insert
  8. In the new field that appears, type:
    $(IFORT_COMPILER[vv])\compiler\lib\ia32
    (remember to substitute for [vv] as described above)
  9. Click OK, OK
  10. In the Visual Studio toolbar, select File > Save All

Property manager View in VS2010/2012

Editing library list in VS2010/2012

If you will be building Intel® 64 (x64) configurations:

  1. Back in the Property Manager, expand the Debug|x64 configuration
  2. Double click on Microsoft.Cpp.x64.user
  3. Select VC++ Directories
  4. Click in the field to the right of "Library Directories"
  5. Click the triangle that appears to the right and select <Edit...>
  6. Click the New Line button or press Ctrl-Insert
  7. In the new field that appears, type:
    $(IFORT_COMPILER[vv])\compiler\lib\intel64
    (remember to substitute for [vv] as described above)
  8. Click OK, OK
  9. In the Visual Studio toolbar, select File > Save All

Click on the Solution Explorer tab, or press Ctrl-Alt-L, to make it visible again.

If you do not see the Microsoft.Cpp.x64.user property page listed for the x64 configuration, right
click on Debug|x64 and select Add Existing property Sheet. Browse to the location which
contains the MsBuild 4.0 property pages. On Windows XP, this is typically:

C:\Documents and Settings\<username>\Local Settings\Application Data\Microsoft\MSBuild\v4.0

On Windows Vista* ,Windows 7* and Windows 8*, it is typically:

C:\Users\<username>\Local Settings\AppData\Local\Microsoft\MSBuild\v4.0

You may need to enable viewing of hidden files and folders to see these paths.

Select Microsoft.Cpp.x64.user.props and click Open. Now follow the steps above.

For more complete information about compiler optimizations, see our Optimization Notice.