<?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 Calling C++ DLL in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941070#M17017</link>
    <description>I am having difficulty with the 'Visual Fortran Calling Visual C Example'.  The example is working fine as is, but following the instructions in the source file I have created a C++ DLL and get the following Fortran linking error &lt;BR /&gt;Compiling Fortran... &lt;BR /&gt;N:	empFortran testVF Calls VCfmain.f90 &lt;BR /&gt;Linking... &lt;BR /&gt;fmain.obj : error LNK2001: unresolved external symbol _C_ROUTINE@20 &lt;BR /&gt;Debug/VF Calls VC.exe : fatal error LNK1120: 1 unresolved externals &lt;BR /&gt;Error executing link.exe. &lt;BR /&gt; &lt;BR /&gt;I have Aliased the DLL function ?c_routine@@YAXHPAD0@Z and confirmed the Exported name matches that in the DLL.  I have also tried exposing _C_ROUTINE@20 in the C++ DLL, but the same error is raised. &lt;BR /&gt; &lt;BR /&gt;I would also like to convert the Fortran into a DLL. Is it possible for a Fortran DLL to make calls to a C++ DLL? or the Fortran DLL to have C++ routines?</description>
    <pubDate>Wed, 28 Feb 2001 21:44:59 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2001-02-28T21:44:59Z</dc:date>
    <item>
      <title>Calling C++ DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941070#M17017</link>
      <description>I am having difficulty with the 'Visual Fortran Calling Visual C Example'.  The example is working fine as is, but following the instructions in the source file I have created a C++ DLL and get the following Fortran linking error &lt;BR /&gt;Compiling Fortran... &lt;BR /&gt;N:	empFortran testVF Calls VCfmain.f90 &lt;BR /&gt;Linking... &lt;BR /&gt;fmain.obj : error LNK2001: unresolved external symbol _C_ROUTINE@20 &lt;BR /&gt;Debug/VF Calls VC.exe : fatal error LNK1120: 1 unresolved externals &lt;BR /&gt;Error executing link.exe. &lt;BR /&gt; &lt;BR /&gt;I have Aliased the DLL function ?c_routine@@YAXHPAD0@Z and confirmed the Exported name matches that in the DLL.  I have also tried exposing _C_ROUTINE@20 in the C++ DLL, but the same error is raised. &lt;BR /&gt; &lt;BR /&gt;I would also like to convert the Fortran into a DLL. Is it possible for a Fortran DLL to make calls to a C++ DLL? or the Fortran DLL to have C++ routines?</description>
      <pubDate>Wed, 28 Feb 2001 21:44:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941070#M17017</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-02-28T21:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calling C++ DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941071#M17018</link>
      <description>Judging on the linker error, you did not declare C routine in fmain.f90 properly. It should look like: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
INTERFACE 
    SUBROUTINE C_ROUTINE(arg1,arg2,arg3,arg4,arg5) 
    !DEC$ATTRIBUTES C, DLLIMPORT, ALIAS: '?c_routine@@YAXHPAD0@Z':: C_ROUTINE 
    END SUBROUTINE 
END INTERFACE 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;Btw, it is recommended to declare the C++ functions exported from dll &lt;BR /&gt;like (in .cpp and .h file): &lt;BR /&gt; &lt;BR /&gt;extern "C" __stdcall c_routine(... &lt;BR /&gt; &lt;BR /&gt;In this way, you get STDCALL instead of C calling convention and usual name mangling (_c_routine@20 instead of C++ type-safe ?c_routine@XYZ...). &lt;BR /&gt; &lt;BR /&gt;Did you insert dll's .lib file into your fortran project? &lt;BR /&gt; &lt;BR /&gt;HTH &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Wed, 28 Feb 2001 23:25:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941071#M17018</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-02-28T23:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling C++ DLL</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941072#M17019</link>
      <description>Thank you for your reply.   &lt;BR /&gt;Checking the the C++ DLL I found the routine exposed was _C_ROUTINE@12 not _C_ROUTINE@20.  So I have added integer arguments for the two strings passed and now it compiles and nearly works.  &lt;BR /&gt;  &lt;BR /&gt;The first string argument is fine but the second is wrong.  This is the C++ routine prototype.  &lt;BR /&gt;  &lt;BR /&gt;extern "C"   &lt;BR /&gt;__declspec(dllexport) void FAR __stdcall C_ROUTINE (int int_arg, char* input_text, int int_input, char* output_text, int int_output);  &lt;BR /&gt;  &lt;BR /&gt;The Fortran interface is declaired as   &lt;BR /&gt;INTERFACE  &lt;BR /&gt;SUBROUTINE c_routine (int_arg, str_in, str_out)  &lt;BR /&gt;Are the arguments in the right order and finally can I make the Fortran into a DLL aswell.  &lt;BR /&gt;  &lt;BR /&gt;Thank you again  &lt;BR /&gt;  &lt;BR /&gt;Terry Hawkes</description>
      <pubDate>Thu, 01 Mar 2001 01:39:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-C-DLL/m-p/941072#M17019</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-03-01T01:39:08Z</dc:date>
    </item>
  </channel>
</rss>

