<?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 You need to link against the  in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985610#M100710</link>
    <description>&lt;P&gt;You need to link against the .lib generated when the DLL was built. If you tried linking to the DLL directly, that was ignored.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2013 18:56:06 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2013-08-28T18:56:06Z</dc:date>
    <item>
      <title>Problem importing Fortran routine from a dll</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985609#M100709</link>
      <description>&lt;P&gt;I have a Fortran console application which is trying to import a routine from a Fortran dll.&amp;nbsp; I'm getting the following error message when linking.&lt;/P&gt;
&lt;P&gt;error LNK2019: unresolved external symbol __imp__USELOG referenced in function _MAIN__&lt;/P&gt;
&lt;P&gt;The interface for the routine is:&lt;BR /&gt;INTERFACE&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SUBROUTINE USELOG(logname, progname, version)&lt;BR /&gt;&lt;B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES, ALIAS:'USELOG' :: USELOG&lt;BR /&gt;&lt;/B&gt;&lt;B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES DLLIMPORT :: USELOG&lt;BR /&gt;&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26) :: logname&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26) :: progname&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN= 5) :: version&lt;BR /&gt;&lt;B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES REFERENCE :: logname, progname, version&lt;BR /&gt;&lt;/B&gt;&amp;nbsp;&amp;nbsp; END SUBROUTINE USELOG&lt;BR /&gt;END INTERFACE&lt;/P&gt;
&lt;P&gt;The routine USELOG uses the following code for exporting:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES DLLEXPORT :: USELOG&lt;BR /&gt;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES ALIAS:'USELOG' :: USELOG&lt;BR /&gt;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES REFERENCE :: logname_, progname_, version_&lt;/P&gt;
&lt;P&gt;When I view the dll using dependency walker the routine is shown as USELOG without any decoration.&lt;/P&gt;
&lt;P&gt;Could someone please tell me how to import this correctly.&lt;/P&gt;
&lt;P&gt;Regards, Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2013 18:46:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985609#M100709</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-28T18:46:24Z</dc:date>
    </item>
    <item>
      <title>You need to link against the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985610#M100710</link>
      <description>&lt;P&gt;You need to link against the .lib generated when the DLL was built. If you tried linking to the DLL directly, that was ignored.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2013 18:56:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985610#M100710</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-08-28T18:56:06Z</dc:date>
    </item>
    <item>
      <title>I did link against the import</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985611#M100711</link>
      <description>&lt;P&gt;I did link against the import lib.&amp;nbsp; I have it listed in the Linker/Advanced/Import Lib.&lt;/P&gt;
&lt;P&gt;I also added the import lib&amp;nbsp;to the project.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2013 19:06:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985611#M100711</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-28T19:06:53Z</dc:date>
    </item>
    <item>
      <title>Ah - I've seen that error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985612#M100712</link>
      <description>&lt;P&gt;Ah - I've seen that error before. That's not the right place to add that. You want it under Additional Dependencies. What you did was tell the linker to name the import library it creates, if it created one, which it won't for an executable project. Treat the import library the same as a static library.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2013 20:20:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985612#M100712</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-08-28T20:20:32Z</dc:date>
    </item>
    <item>
      <title>You are correct Steve.  I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985613#M100713</link>
      <description>&lt;P&gt;You are correct Steve.&amp;nbsp; I think I moved the import lib address from the Additional Dependencies in an attempt to fix the original problem which is an unresolved external.&lt;/P&gt;
&lt;P&gt;I am trying to use the routine USELOG from the dll.&amp;nbsp; If I use an interface block in the calling program, I get this error:&lt;BR /&gt;error LNK2019: unresolved external symbol __imp__USELOG referenced in function _MAIN__&amp;nbsp;Besthb.obj&lt;/P&gt;
&lt;P&gt;If I do not use an interface block, I get the following error:&lt;BR /&gt;error LNK2019: unresolved external symbol _USELOG referenced in function _MAIN__&lt;/P&gt;
&lt;P&gt;Both errors say that the linker&amp;nbsp;is looking for the routine USELOG with&amp;nbsp;a prefix to the routine name.&lt;/P&gt;
&lt;P&gt;Dependency Walker does not show any prefix when looking at the dll.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 11:37:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985613#M100713</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-29T11:37:32Z</dc:date>
    </item>
    <item>
      <title>I decided to try a different</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985614#M100714</link>
      <description>&lt;P&gt;I decided to try a different approach.&amp;nbsp; I created a static library to replace the dll.&amp;nbsp; I added that as the additional dependency instead of the dll import library.&amp;nbsp; I eliminated the Interface block.&amp;nbsp; However, I still get the error:&lt;BR /&gt;error LNK2019: unresolved external symbol _USELOG referenced in function _MAIN__&lt;/P&gt;
&lt;P&gt;The USELOG routine does show up as _USELOG in a Dumpbin listing of the static library.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 12:35:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985614#M100714</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-29T12:35:54Z</dc:date>
    </item>
    <item>
      <title>I solved the underlying</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985615#M100715</link>
      <description>&lt;P&gt;I solved the underlying problem.&lt;/P&gt;
&lt;P&gt;In the UseLog routine being exported from the dll, the DECORATE command was missing.&lt;/P&gt;
&lt;P&gt;The codes should have read:&lt;BR /&gt;!DEC$ ATTRIBUTES DLLEXPORT :: USELOG&lt;BR /&gt;!DEC$ ATTRIBUTES &lt;STRONG&gt;DECORATE&lt;/STRONG&gt;, ALIAS:'USELOG' :: USELOG&lt;BR /&gt;!DEC$ ATTRIBUTES REFERENCE :: logname_, progname_, version_&lt;/P&gt;
&lt;P&gt;Question: Is it possible to tell the calling routine not to expect decoration?&lt;/P&gt;
&lt;P&gt;Regards, Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 14:40:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985615#M100715</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-29T14:40:38Z</dc:date>
    </item>
    <item>
      <title>You could remove the ALIAS</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985616#M100716</link>
      <description>&lt;P&gt;You could remove the ALIAS,DECORATE directive entirely in both the called routine and the caller. since all you're doing is restating the default.&lt;/P&gt;
&lt;P&gt;When you use DLLIMPORT, the __imp__prefix is added. This is resolved by the import library and tells the linker to optimize the call (removes a few extra instructions. You don't see the prefix when examining the library or DLL. DLLIMPORT is optional when calling procedures, but is required if you are referencing variables or COMMON blocks in DLLs.&lt;/P&gt;
&lt;P&gt;I will also comment that a nice way to handle this sort of thing is to put your DLL routine in a module, with DLLEXPORT. Then when the called program USEs the module, it will automatically get the interface AND do a DLLIMPORT. DO make sure that the executable links to the DLL run-time libraries.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 14:47:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985616#M100716</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-08-29T14:47:15Z</dc:date>
    </item>
    <item>
      <title>I use modules in VB, but</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985617#M100717</link>
      <description>&lt;P&gt;I use modules in VB, but haven't used them in Fortran.&lt;/P&gt;
&lt;P&gt;Are you suggesting placing the entire routine in a module like the sample code below, or only a interface block?&lt;/P&gt;
&lt;P&gt;MODULE MOD_TEST&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; SUBROUTINE UseLog(logname, progname, version)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; !DEC$ ATTRIBUTES DLLEXPORT :: USELOG&lt;BR /&gt;&amp;nbsp; !DEC$ ATTRIBUTES REFERENCE :: logname, progname, version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; IMPLICIT NONE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; INTERFACE &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUBROUTINE USE_LOG(logname, progname, version);&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES DLLIMPORT :: USE_LOG&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES DECORATE, ALIAS:'use_log' :: USE_LOG&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26) :: logname&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26) :: progname&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=5)&amp;nbsp; :: version&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !DEC$ ATTRIBUTES REFERENCE :: logname, progname, version&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END SUBROUTINE USE_LOG &lt;BR /&gt;&amp;nbsp;&amp;nbsp; END INTERFACE &lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Type call list variables&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26), INTENT(IN) :: logname &lt;BR /&gt;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=26), INTENT(IN) :: progname&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CHARACTER(LEN=5),&amp;nbsp; INTENT(IN) :: version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; CALL Use_Log(logname, progname, version)&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; RETURN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; END SUBROUTINE UseLog&lt;BR /&gt;END MODULE_TEST&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 16:06:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985617#M100717</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-29T16:06:52Z</dc:date>
    </item>
    <item>
      <title>You would take out the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985618#M100718</link>
      <description>&lt;P&gt;You would take out the INTERFACE - a routine in a module provides its own interface. See &lt;A href="http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again"&gt;Doctor Fortran Gets Explicit - Again!&lt;/A&gt; for more information. Then add a USE MOD_TEST to the main program where you want the subroutine to be visible. You'll need to make the .mod file created when the module was compiled visible to the "Includes" path when building the executable. If you simply make the DLL project a dependent of the executable project, everything will be done automatically.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 16:25:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985618#M100718</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-08-29T16:25:12Z</dc:date>
    </item>
    <item>
      <title>In the sample code, the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985619#M100719</link>
      <description>&lt;P&gt;In the sample code, the INTERFACE is actually for the routine USE_LOG&amp;nbsp; which is a C routine in another dll.&amp;nbsp; The Fortran routine USELOG is calling USE_LOG.&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 16:36:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985619#M100719</guid>
      <dc:creator>Kipling__Michael</dc:creator>
      <dc:date>2013-08-29T16:36:59Z</dc:date>
    </item>
    <item>
      <title>Ah, I see. Yes, you need an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985620#M100720</link>
      <description>&lt;P&gt;Ah, I see. Yes, you need an interface for the C routine.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 17:12:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-importing-Fortran-routine-from-a-dll/m-p/985620#M100720</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-08-29T17:12:14Z</dc:date>
    </item>
  </channel>
</rss>

