Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26731 Discussions

Calling Microsoft C++ from Intel Visual Fortran

schulzey
New Contributor I
187 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
Black Belt
187 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?
 

schulzey
New Contributor I
187 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.

IanH
Black Belt
187 Views

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

TimP
Black Belt
187 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.

FortranFan
Honored Contributor II
187 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

Reply