Configuring Visual Studio for Mixed-Language Applications

 Intel® Parallel Studio XE 2017 supports Microsoft Visual Studio 2015, 2013, and 2012. In the text below, substitute 17 where [vv] is shown.Introduction

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

  • Intel® Parallel Studio XE 2018 supports Microsoft Visual Studio 2017, 2015, and 2013. In the text below, substitute 18 where [vv] is shown.
  • Intel® Parallel Studio XE 2017 supports Microsoft Visual Studio 2015, 2013, and 2012. In the text below, substitute 17 where [vv] is shown.
  • Intel® Parallel Studio XE 2016 supports Microsoft Visual Studio 2015, 2013, 2012 and 2010. In the text below, substitute 16 where [vv] is shown.
  • 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 2015, 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. If your C++ project references ISO_Fortran_binding.h, also add libifcoremd.lib to Additional Dependencies.

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 "Include 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\include
    (remember to substitute for [vv] as described above)
  9. Click OK
  10. Click in the field to the right of "Library Directories"
  11. Click the triangle that appears to the right and select <Edit...>
  12. Click the New Line button or press Ctrl-Insert
  13. In the new field that appears, type:
    $(IFORT_COMPILER[vv])\compiler\lib\ia32
    (remember to substitute for [vv] as described above)
  14. Click OK, OK
  15. In the Visual Studio toolbar, select File > Save All

Property manager View in VS2010/2012

cpp property page

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 "Include 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\include
    (remember to substitute for [vv] as described above)
  8. Click OK
  9. Click in the field to the right of "Library Directories"
  10. Click the triangle that appears to the right and select <Edit...>
  11. Click the New Line button or press Ctrl-Insert
  12. In the new field that appears, type:
    $(IFORT_COMPILER[vv])\compiler\lib\intel64
    (remember to substitute for [vv] as described above)
  13. Click OK, OK
  14. 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 later 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 Help

If you need further assistance with configuring Visual Studio to link with Fortran, please ask in our User Forum.

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

7 comments

Top
Zahra A.'s picture

Dear Steve,

I have a problem with compiling fortran programs in visual studio. I have used visual studio 2010 and 2008 and Intel Visual Fortran Compose 13 and 15. When I debug the ".for" programs, I face with these errors:

Error    1    error LNK2001: unresolved external symbol _mainCRTStartup    

Error    2    error LNK1120: 1 unresolved externals    

I have done what you wrote on this page but I still face the same errors. I should say that I can compile and run the ".f90" program without any problems, and these errors are just for ".for" program.

Please help me to solve this problem.

Steve Lionel (Intel)'s picture

Fritz, if you use "ifort" to link, you should not need anything else. The instructions in this article are for people using Visual C++ main applications. If you need further help,please ask in our user forum.

Fritz Lang's picture

I am trying to link FORTRAN with ASM; the principal routine (PROGRAM) is under FORTRAN; I use command line instructions.
The following are both my compile and link instructions...

iFORT %1.FOR /align:all /c /tune:pn2 /fp:strict /Qprec /Qprec-div /ccdefault:fortran /w90 /w95 /error-limit:20 /4I4 /Qzero /GS /f66 /f77rtl

ML32 /c FMATCH_32bit
ML32 /c UTIL5_32bit

xiLINK /subsystem:console /out:TestUtil.EXE @LN32UT.XXX

with LN32UT being:
TestUtil.OBJ XFOS1AA.OBJ XFOS1AB.OBJ XFOS1AC.OBJ XFOS1AD.OBJ SCROLL.OBJ [all FORTRAN]
FMATCH_32bit.OBJ UTIL5_32bit.OBJ [Assembler code]

Do I need an LIB (or something ???).

Steve Lionel (Intel)'s picture

No custom build steps are needed. See discussion in the thread you started at http://software.intel.com/en-us/forums/showthread.php?t=79292

mikilbhatkar's picture

I need to use Intel compiler for projects in which we have both .FOR and .CPP files.

Do we need custom build steps for this ?

anonymous's picture

I have a project containing .FOR and .cpp files. Now I am unable to build those projects using Intel Compiler. Do I need to add custom build steps for .FOR files or something else ?

anonymous's picture

$(IFORT_COMPILER11)libia32 should be $(IFORT_COMPILER11)libia32

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.