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

Calling Microsoft C++ from Intel Visual Fortran

schulzey
New Contributor I
519 Views

What is the best way to call a Microsoft C++ routine from Intel Visual Fortran? I would prefer to create a MS C++ library and then link it into my application and call it direct rather than making a C++ DLL and then calling the DLL.

0 Kudos
5 Replies
IanH
Honored Contributor II
519 Views

That's a pretty broad question. You can do what you prefer (C++ static library that a Fortran program links to, or vice versa). Is there some particular aspect that you want more information on?
 

0 Kudos
schulzey
New Contributor I
519 Views

Apologies if it was too broad. I would prefer a MS C++ static library that I would just call from Intel Fortran. I would just set up a data structure in the Fortran and pass its pointer to the C++ routine which would contain an equivalent structure. How to pass the data back and forth is not a problem.

The main thing I'm unsure about is what pragmas, etc are required in the Fortran and C++ so that they link and communicate with each other properly.

0 Kudos
IanH
Honored Contributor II
519 Views

Declare the C++ function with extern "C", use BIND(C) on the Fortran side, and in general away you go...

0 Kudos
TimP
Honored Contributor III
519 Views

For usage of BIND(C) there are useful examples you can find by search engines (perhaps as ISO C interop).  Fortunately, this is an aspect of Fortran which generally is treated accurately.  Multiple rank arrays aren't so pretty.

0 Kudos
FortranFan
Honored Contributor II
519 Views

schulzey wrote:

Apologies if it was too broad. I would prefer a MS C++ static library that I would just call from Intel Fortran. I would just set up a data structure in the Fortran and pass its pointer to the C++ routine which would contain an equivalent structure. How to pass the data back and forth is not a problem.

The main thing I'm unsure about is what pragmas, etc are required in the Fortran and C++ so that they link and communicate with each other properly.

See this thread on this forum, quote #6 for an example:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/699941

0 Kudos
Reply