Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Is it possible to compile C++ and Fortran source code together?

junhonguk
Beginner
912 Views
I have installed Intel Visual Fortran (9.1) in Visual Studio 2002 IDE.
I wonder if it is possible to compile a Visual Fortran Project within which contains C/C++ source code.

Is there anyway to set up the compiler environment and let the compiler manager automatically detect C/C++ source code and choose visual C++ compiler to compiler without through static or dynamic link library?

By the way, I have managed to create a static library for C++ code and include it within the visual fortran project, where it can recognise the subroutines written in C/C++.

Thanks and looks forward to your reply.
0 Kudos
1 Solution
Steven_L_Intel1
Employee
912 Views
The samples use 11.1 project files and won't be openable by 9.1. Here's the general overview.

  1. First, configure Visual Studio for mixed-language development.
  2. Create the main program project, either Fortran or C++
  3. Add to the solution a new static library project of the other language
  4. Right click on the main program project, select Project Dependencies. Check the box for the static library
  5. In each project, look at the setting for runtime libraries and make sure that they are the same. In C++ it's under Code Generation, in Fortran, Libraries
  6. If the Fortran project is a static library, go to the Libraries property page and set "Disable default library search rules" to "No".
Now you just have to make sure that you have the calling conventions and routine names consistent. Read the Fortran documentation section on mixed-language programming.

View solution in original post

0 Kudos
5 Replies
bmchenry
New Contributor II
912 Views
a good starting point is the example directory.
from windows explorer browse to INTEL/Compiler/11.1/048/Samples/en_US/Fortran
(note the structure for 9.1 is similar/same, so simply browse around in the INTEL install directory)
(Also, back in 9.1 they may have had the examples un-zipped. with current release you need to un-zip the examples)
you'll find ZIP files, one titled Mixed Language
has solution with mixed language whcih does what you want/need
Also in the Fortran User Guide -> see Building Applications ->Programming with mixed languages
will also answere your questions about including libraries built in other languages.

0 Kudos
Steven_L_Intel1
Employee
912 Views
9.1 doesn't have the samples.
0 Kudos
junhonguk
Beginner
912 Views
9.1 doesn't have the samples.
You are right.
Could you be kind enough to send me the relevant sample zip files regarding to Mixed Languages?
Many thanks.
My email address is: junhonguk@gmail.com
0 Kudos
Steven_L_Intel1
Employee
913 Views
The samples use 11.1 project files and won't be openable by 9.1. Here's the general overview.

  1. First, configure Visual Studio for mixed-language development.
  2. Create the main program project, either Fortran or C++
  3. Add to the solution a new static library project of the other language
  4. Right click on the main program project, select Project Dependencies. Check the box for the static library
  5. In each project, look at the setting for runtime libraries and make sure that they are the same. In C++ it's under Code Generation, in Fortran, Libraries
  6. If the Fortran project is a static library, go to the Libraries property page and set "Disable default library search rules" to "No".
Now you just have to make sure that you have the calling conventions and routine names consistent. Read the Fortran documentation section on mixed-language programming.
0 Kudos
junhonguk
Beginner
912 Views
The samples use 11.1 project files and won't be openable by 9.1. Here's the general overview.

  1. First, configure Visual Studio for mixed-language development.
  2. Create the main program project, either Fortran or C++
  3. Add to the solution a new static library project of the other language
  4. Right click on the main program project, select Project Dependencies. Check the box for the static library
  5. In each project, look at the setting for runtime libraries and make sure that they are the same. In C++ it's under Code Generation, in Fortran, Libraries
  6. If the Fortran project is a static library, go to the Libraries property page and set "Disable default library search rules" to "No".
Now you just have to make sure that you have the calling conventions and routine names consistent. Read the Fortran documentation section on mixed-language programming.

Really appreciate for your gudiance.
It is very useful.
0 Kudos
Reply