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

DLL_Export Help

jjfait
Beginner
624 Views

Hi, I am using Intel Fortran v.10 and was wondering how to use whatI used in Lahey by calling

DLL_EXPORT :: SubroutineName

I am note sure if its an option i have chosen but it obviously doesnt compline. I also tried something i found a couple people used

!cDEC$ ATTRIBUTES DLLEXPORT :: SubroutineName,either commented or not

So I get the error, not able to make an entry point, which seems like it is not finding the subroutine.

Any help is appreciated

Jeremy

0 Kudos
5 Replies
Steven_L_Intel1
Employee
624 Views
You're close. Remove the c after the !. That's the way it's done in Intel Fortran - this is a directive that has the form of a comment. For more information, see the chapter on Directive Enhanced Compilation in the on-disk documentation.
0 Kudos
jjfait
Beginner
624 Views

ok, that seemed to make the statement 'uncommented', so i compiled it and put it in my C# debug file and it still gives me the same error, no entry point, a made a very basic program to make this call, the subroutine for fortran looks like:

Subroutine

Gauss(i)

!DEC$ ATTRIBUTES DLLEXPORT :: Gauss

implicit none

integer

i

i = 3

end subroutine

The way that i've done it for VS2003 fortran is, from c# i would say:

[

DllImport("RadLabLibrary.dll", CallingConvention = CallingConvention.StdCall)]

public static extern void Gauss(ref int intNum);

at the top of the class, where RadLabLibrary is the dll in my c# debug file, and then i would make the call: Gauss(i), is this still the same for Intel Fortran, am i missing an option somewhere or why is not finding an entry point , thanks

Jeremy

0 Kudos
Steven_L_Intel1
Employee
624 Views
You need to say, in C++:

extern "C" void GAUSS

Fortran upcases names by default and you need the "C" to avoid C++ name mangling. If you don't want to change the name, use this in Fortran instead:

!DEC$ ATTRIBUTES DLLEXPORT,DECORATE,ALIAS:"Gauss" :: Gauss

Also, remove the calling convention specification from the C++, as STDCALL is not the default in Intel Fortran.
0 Kudos
jjfait
Beginner
624 Views

so in C# (or C++) you have to name the subroutine GAUSS capitalized or do that other dllexport call,

what isinteresting is that i never had to do that with Lahey fortran i could just say Gauss_f or whatever,

is lahey one of the few compiliers who do that? i forget what the stdcall was used for but use to be necessary

now if i could just figure out how to get lahey VS03 IMSL library to work i would be set, thanks for your help

Jeremy

0 Kudos
Steven_L_Intel1
Employee
624 Views
Since C++ is case-sensitive, the procedure name must be spelled exactly the way the Fortran compiler will generate the global symbol. The defaults for this vary among compilers.

I can't imagine how Lahey manages to resolve the case-sensitivity of C++ with the case-insensitivity of Fortran. STDCALL would be used if you were using Compaq Visual Fortran, but not for Intel Visual Fortran.
0 Kudos
Reply