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

Mixed Language DLL

hweisberg
Beginner
629 Views
I am using CVF to create a DLL from mixed Fortran and Assembly files.

I export the entry point to a Fortran routine by using the DLLEXPORT directive:

subroutine MyFortranRoutine(x, y)
!DEC$ ATTRIBUTES DLLEXPORT::MYFORTRANROUTINE
...
end

How do I export the entry point to an assembly routine?

I don't want to just wrap the assembly routine in a Fortran wrapper function which I then export.

The assembly routine looks like this:

MYASSEMBLYROUTINE PROC STDCALL, x:SDWORD, y:SDWORD extrn _z@12:proc
...
MyAssemblyRoutine ENDP

0 Kudos
8 Replies
Steven_L_Intel1
Employee
629 Views
I don't know if MASM has a "DLLEXPORT" directive/pragma/whatever. Perhaps one uses a .DEF file for this?

Steve
0 Kudos
gfthomas8
Novice
629 Views
Steve is on to something when he suggests using a .DEF. See

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_10.htm

BTW kb Q228545 has a patch 6.14 for masm.

Please post back on your success and any uncovered pitfalls.

HTH,
Gerry T.
0 Kudos
hweisberg
Beginner
629 Views
OK, there is a MASM611SAMPLESWINDLL folder that shows how to make an all-MASM DLL.

Not being extreme MASM experts, we are going to have a hard time using this to devine the one or two lines of code that perhaps would solve our problem within CVF, where we just want to add one entry point.

The development environment doesn't seem to have a place for adding .DEF files. There seems to be a .EXP file already that defines exports.

Anyu experts out there who know the answer?
0 Kudos
Steven_L_Intel1
Employee
629 Views
Just add the .DEF as if it was a source file. It will get picked up automatically by the linker. I have done this (just not with MASM.)

Steve
0 Kudos
hweisberg
Beginner
629 Views
What should the DEF file look like? Should it export WEP and/or the entry points that are already exported by the DLLEXPORT directives in my Fortran routines?

I tried putting the following .DEF file in the same folder as my source files, but according to DUMPBIN it didn't add the export (MyAsmFunction) that I specified:

LIBRARY MyDll
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
SEGMENTS CODE2 PRELOAD FIXED
EXPORTS MyAsmFunction
0 Kudos
Steven_L_Intel1
Employee
629 Views
Simply placing the .DEF file in the source directory is insufficient - you have to be sure that it is an input to the linker, similar to a .OBJ. That's what adding it as a project source would do.

I've used .DEF files a little. I think the EXPORTS keyword is supposed to be on a line by itself, then followed by lines naming the exports. I also think that proper case for the symbol name is important.

Steve
0 Kudos
durisinm
Novice
629 Views
I did a search on Microsoft's site for Q228545 and got no results. Is that number correct?

Mike
0 Kudos
Jugoslav_Dujic
Valued Contributor II
629 Views
Actually, it's 228454.

Jugoslav
0 Kudos
Reply