<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Generic Procedure export problem in creating DLL in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820237#M47332</link>
    <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=521160" class="basic" href="https://community.intel.com/en-us/profile/521160/"&gt;chshaoning&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;...&lt;BR /&gt;In a MODULE of the main programm I try to call the exported functions directly use CALL SET_VARIABLE without using a !DEC$ ATTRIBUTE DLLIMPORT :: [the function Name]. And I got the error at Compiling like this:&lt;BR /&gt;&lt;I&gt;Fehler1 error LNK2019: Verweis auf nicht aufgelstes externes Symbol "_SET_VARIABLE" in Funktion "_M_IF_AGMA2101_mp_IF_AGMA2101".M_IF_AGMA2101.obj &lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This mising symbol isn't decorated with the _MODULENAME_mp_ prefix, which indicates that the compiler thinks that procedure represented by the symbol is just a normal external procedure (not a module procedure). As per mecej4's example, the SET_VARIABLE interface needs to be PUBLIC in the module that defines it (everything in the module in his example is PUBLIC by default) and you need the appropriate USE M_ID_AGMA2101 statement in the scope where CALL SET_VARIABLE appears.&lt;/P&gt;&lt;P&gt;Note that it is illegal code to separately specify an interface for a module procedure (like you've done in the second stretch of code in post four with the subroutine statements inside the interface block). The interfaces for a module procedure must only be accessed by a USE statement.&lt;/P&gt;&lt;P&gt;Rather than tying my code to a particular compiler's name mangling scheme, I prefer to use the BIND suffix on the definitions of the individial procedures to give the procedure a linker name of my choosing. If the procedure has an external linker name, making it private seems a bit counter-intuitive to me, but I guess it has to work.&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2011 22:59:39 GMT</pubDate>
    <dc:creator>IanH</dc:creator>
    <dc:date>2011-05-19T22:59:39Z</dc:date>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820231#M47326</link>
      <description>In our project we have created a generic procedure like this:&lt;BR /&gt;&lt;P&gt;&lt;STRONG&gt;INTERFACE SET_VARIABLE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MODULE PROCEDURE&lt;/STRONG&gt; SET_VARIABLE_REAL&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MODULE PROCEDURE&lt;/STRONG&gt; SET_VARIABLE_INTEGER&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MODULE PROCEDURE&lt;/STRONG&gt; SET_VARIABLE_REAL_ARRAY&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MODULE PROCEDURE&lt;/STRONG&gt; SET_VARIABLE_INTEGER_ARRAY&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;END INTERFACE SET_VARIABLE&lt;BR /&gt;&lt;/STRONG&gt;this interface is defined in a Module and also the module procedure. We want to export the &lt;STRONG&gt;SET_VARIABLE &lt;/STRONG&gt;as the dll-function for main_programm. But we don't know how. I want to know if it's possible to export it and HOW?&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2011 12:00:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820231#M47326</guid>
      <dc:creator>chshaoning</dc:creator>
      <dc:date>2011-05-19T12:00:49Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820232#M47327</link>
      <description>When the compiler processes Fortran code that calls a procedure by its generic name, it resolves the specific name to be used by examining the types of the arguments. Therefore, there need to be exported routines in the DLL matching all the specific names that are needed to satisfy the calls. One (and only one) of the specific names is allowed to coincide with the generic name.&lt;BR /&gt;&lt;BR /&gt;For example, with the four specific subroutines that are involved in your example, withe module named as SETVMOD, the following module definition file will work.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]LIBRARY mproc.dll
EXPORTS
SETVMOD_mp_SET_VARIABLE_INTEGER
SETVMOD_mp_SET_VARIABLE_INTEGER_ARRAY
SETVMOD_mp_SET_VARIABLE_REAL
SETVMOD_mp_SET_VARIABLE_REAL_ARRAY
[/bash]&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2011 12:57:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820232#M47327</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-05-19T12:57:28Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820233#M47328</link>
      <description>hi mecej4:&lt;BR /&gt;&lt;BR /&gt;I tried your methode. But it semms not working. I tried to use the general name "SET_VARIABLE", but i got a bug.</description>
      <pubDate>Thu, 19 May 2011 14:43:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820233#M47328</guid>
      <dc:creator>chshaoning</dc:creator>
      <dc:date>2011-05-19T14:43:41Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820234#M47329</link>
      <description>It certainly works. If you show what you tried and what the error messages were, we could get things working. Simply saying "I got a bug" takes us nowhere.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 May 2011 15:46:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820234#M47329</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-05-19T15:46:53Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820235#M47330</link>
      <description>Thank you for the answer.&lt;BR /&gt;OK. I try to explain my problem in detail.&lt;BR /&gt;As in the question mentioned we put a INTERFACE in a MODULE for different types of parameter. The MODULE PROCEDURE are defined in the MODULE as PRAVITE. I defined in the .def file the EXPORTS as below.&lt;BR /&gt;...&lt;BR /&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;P&gt;EXPORTS&lt;BR /&gt;SET_VARIABLE_REAL = M_ID_AGMA2101_mp_SET_VARIABLE_REAL&lt;/P&gt;&lt;P&gt;SET_VARIABLE_INTEGER = M_ID_AGMA2101_mp_SET_VARIABLE_INTEGER&lt;/P&gt;&lt;P&gt;SET_VARIABLE_REAL_ARRAY = M_ID_AGMA2101_mp_SET_VARIABLE_REAL_ARRAY&lt;/P&gt;&lt;P&gt;SET_VARIABLE_INTEGER_ARRAY = M_ID_AGMA2101_mp_SET_VARIABLE_INTEGER_ARRAY&lt;/P&gt;&lt;/SPAN&gt;...&lt;BR /&gt;In a MODULE of the main programm I try to call the exported functions directly use CALL SET_VARIABLE without using a !DEC$ ATTRIBUTE DLLIMPORT :: [the function Name]. And I got the error at Compiling like this:&lt;BR /&gt;&lt;EM&gt;Fehler1 error LNK2019: Verweis auf nicht aufgelstes externes Symbol "_SET_VARIABLE" in Funktion "_M_IF_AGMA2101_mp_IF_AGMA2101".M_IF_AGMA2101.obj&lt;/EM&gt;&lt;BR /&gt;And then I tried another way. I puted a INTERFACE in the MODULE of the main programm like this:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-size: x-small;"&gt;&lt;SPAN style="color: #008000; font-size: x-small;"&gt;&lt;P&gt;INTERFACE &lt;BR /&gt;SUBROUTINE SET_VARIABLE_INTEGER(NM_VARIABLE,VL_VARIABLE)&lt;BR /&gt; !DEC$ ATTRIBUTES DLLIMPORT :: SET_VARIABLE_INTEGER&lt;BR /&gt;END SUBROUTINE SET_VARIABLE_INTEGER&lt;BR /&gt;SUBROUTINE SET_VARIABLE_REAL(NM_VARIABLE,VL_VARIABLE)&lt;BR /&gt; !DEC$ ATTRIBUTES DLLIMPORT :: SET_VARIABLE_REAL&lt;BR /&gt;END SUBROUTINE&lt;BR /&gt;...&lt;BR /&gt;END INTERFACE&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;and I got same error like before. At last I tried to put SET_VARIABLE behind the INTERFACE keyword and got the error below.&lt;BR /&gt;&lt;EM&gt;Fehler1 error #6285: There is no matching specific subroutine for this generic subroutine call. [SET_VARIABLE]&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;I think I made somewhere a mistake. Can you tell me the right way to do that?</description>
      <pubDate>Thu, 19 May 2011 17:39:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820235#M47330</guid>
      <dc:creator>chshaoning</dc:creator>
      <dc:date>2011-05-19T17:39:31Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820236#M47331</link>
      <description>I think that you ran into problems because the substitution of generic names by specific names, name substitution by DEC$ directives and name substitution through the .DEF all have the potential to interact and, if not done correctly and in the proper order, will cause clashes.&lt;BR /&gt;&lt;BR /&gt;Here is a simpler solution, which does not need renaming DLL symbols or directives.&lt;BR /&gt;&lt;BR /&gt;First, the source for building the DLL and the .mod file, mproc.f90:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]module setvmod
  INTERFACE SET_VARIABLE
    module procedure SET_VARIABLE_REAL
    module procedure SET_VARIABLE
    module procedure SET_VARIABLE_REAL_ARRAY
    module procedure SET_VARIABLE_INTEGER_ARRAY
  END INTERFACE
contains
  subroutine set_variable(x,v)
  integer,intent(out) :: x
  integer,intent(in) :: v
  x=v
  return
  end subroutine set_variable

  subroutine set_variable_real(x,v)
  real,intent(out) :: x
  real,intent(in) :: v
  x=v
  return
  end subroutine set_variable_real

  subroutine set_variable_integer_array(x,v)
  integer,intent(out) :: x(:)
  integer,intent(in) :: v(:)
  x=v
  return
  end subroutine set_variable_integer_array

  subroutine set_variable_real_array(x,v)
  real,intent(out) :: x(:)
  real,intent(in) :: v(:)
  x=v
  return
  end subroutine set_variable_real_array
end module setvmod
[/fortran]&lt;/PRE&gt; The .def file, mproc.def :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]LIBRARY mproc.dll
EXPORTS
SETVMOD_mp_SET_VARIABLE
SETVMOD_mp_SET_VARIABLE_INTEGER_ARRAY
SETVMOD_mp_SET_VARIABLE_REAL
SETVMOD_mp_SET_VARIABLE_REAL_ARRAY
[/bash]&lt;/PRE&gt; Building the DLL and the import library for it:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]s:&amp;gt; lib /def:mproc.def /machine:i386
s:&amp;gt; ifort /LD mproc.f90 mproc.exp
[/bash]&lt;/PRE&gt; The main program which uses the module and will call the DLL for the module procedures, tmproc.f90:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]program tmproc
use setvmod
integer :: i,ia(5),j,ja(5)
real :: x,xa(5),y,ya(5)

do i=1,5
  ia(i)=i*2-3
  xa(i)=i*2.5-4.5
end do

j=3; call set_variable(i,j); write(*,*)i
call set_variable(ja,ia); write(*,*)ja
y=3.5; call set_variable(x,y); write(*,*)x
call set_variable(ya,xa); write(*,*)ya
end program tmproc
[/fortran]&lt;/PRE&gt; Build and run the program:&lt;BR /&gt;&lt;PRE&gt;[bash]s:LANG&amp;gt;ifort tmproc.f90 mproc.lib
s:LANG&amp;gt;tmproc
           3
          -1           1           3           5           7
   3.500000
  -2.000000      0.5000000       3.000000       5.500000       8.000000 [/bash]&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2011 18:16:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820236#M47331</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-05-19T18:16:36Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820237#M47332</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=521160" class="basic" href="https://community.intel.com/en-us/profile/521160/"&gt;chshaoning&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;...&lt;BR /&gt;In a MODULE of the main programm I try to call the exported functions directly use CALL SET_VARIABLE without using a !DEC$ ATTRIBUTE DLLIMPORT :: [the function Name]. And I got the error at Compiling like this:&lt;BR /&gt;&lt;I&gt;Fehler1 error LNK2019: Verweis auf nicht aufgelstes externes Symbol "_SET_VARIABLE" in Funktion "_M_IF_AGMA2101_mp_IF_AGMA2101".M_IF_AGMA2101.obj &lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This mising symbol isn't decorated with the _MODULENAME_mp_ prefix, which indicates that the compiler thinks that procedure represented by the symbol is just a normal external procedure (not a module procedure). As per mecej4's example, the SET_VARIABLE interface needs to be PUBLIC in the module that defines it (everything in the module in his example is PUBLIC by default) and you need the appropriate USE M_ID_AGMA2101 statement in the scope where CALL SET_VARIABLE appears.&lt;/P&gt;&lt;P&gt;Note that it is illegal code to separately specify an interface for a module procedure (like you've done in the second stretch of code in post four with the subroutine statements inside the interface block). The interfaces for a module procedure must only be accessed by a USE statement.&lt;/P&gt;&lt;P&gt;Rather than tying my code to a particular compiler's name mangling scheme, I prefer to use the BIND suffix on the definitions of the individial procedures to give the procedure a linker name of my choosing. If the procedure has an external linker name, making it private seems a bit counter-intuitive to me, but I guess it has to work.&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2011 22:59:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820237#M47332</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-05-19T22:59:39Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820238#M47333</link>
      <description>There was no mention of PUBLIC/PRIVATE before your reply, so I am somewhat puzzled by why you brought it up. &lt;BR /&gt;&lt;BR /&gt;Anyway, the accessibility of the generic routine is separate from the accessibility of the specific routines, so one could add&lt;BR /&gt;&lt;PRE&gt;[fortran]  private
  public :: set_variable
[/fortran]&lt;/PRE&gt; after Line-1 in #5. The linker, however, usually does not inherit (courtesy of the compiler) PUBLIC/PRIVATE attributes, so the module definition file needs to contain entries for even the private procedure names.&lt;BR /&gt;</description>
      <pubDate>Fri, 20 May 2011 00:11:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820238#M47333</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-05-20T00:11:12Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820239#M47334</link>
      <description>Agreed - it's just the OP had said that he'd marked the specific procedures as private (in post 4). If he's done that by setting the default accessibility for the module to private, but then forgotten to mark the generic as public, you'd get the symptoms that he's describing (you'd also get them if you simply forgot to USE the defining module).&lt;BR /&gt;&lt;BR /&gt;Marking procedures that must be exported in a DLL private bothers me a little because you've got supposedly internal implementation detail (private procedure names and entry points) "visible" to the outside world. Normally such externally visible interfaces (in the non-fortran sense) to bits of code need to be well controlled - changes to the name or argument list require everything that dynamically links to the interface to be recompiled. When something is private to a module I take it as a cue that I can interfere with it within the confines of the module as much as I please, but that's not the case here.&lt;BR /&gt;&lt;BR /&gt;(Some compilers do not emit a external link name for private entities when they are sure that the procedure can not be referenced from outside the module (not the case here with ifort's implementation - if the generic interface is public then the private procedure must have an external link name). Some compilers (including ifort at one stage, might be fixed now) omit the external name in corner cases where it is still required, causing link errors.)</description>
      <pubDate>Fri, 20 May 2011 00:48:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820239#M47334</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2011-05-20T00:48:41Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820240#M47335</link>
      <description>It's fine to have the specific procedures private - the compiler has to know how to deal with that. Accessibility is about whether source code can reference the name, not whether it is invisible to the compiler. You do, however,&lt;BR /&gt;have to DLLEXPORT all the specific procedures that may be referenced in a DLL.</description>
      <pubDate>Fri, 20 May 2011 01:30:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820240#M47335</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-05-20T01:30:34Z</dc:date>
    </item>
    <item>
      <title>Generic Procedure export problem in creating DLL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820241#M47336</link>
      <description>Thanks to all. With your professional answer I solved my problem.</description>
      <pubDate>Fri, 20 May 2011 08:58:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Generic-Procedure-export-problem-in-creating-DLL/m-p/820241#M47336</guid>
      <dc:creator>chshaoning</dc:creator>
      <dc:date>2011-05-20T08:58:07Z</dc:date>
    </item>
  </channel>
</rss>

