<?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 Re: c++ calling fortran dll linker error in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841435#M59404</link>
    <description>&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;IusedDECORATE and ALIAS without the leading underscore. The only thing I forgot to do was to include the .lib in c++ project. Now I have added .lib to roject and kept .lib and .dll in path of c++ exe. It works fine now. Thanks for your help. Final code is as below:&lt;/P&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;---------------------Fortran Code--------------------&lt;/P&gt;
&lt;P&gt;subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES DLLEXPORT:: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES C, DECORATE, ALIAS:'TestCode':: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;print&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;*, "Say Hello from Fortran"&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;end subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;#include&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; "stdafx.h"&lt;P&gt;&lt;/P&gt;
&lt;P&gt;------------------C++ code -------------------&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;extern&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; "C" &lt;P&gt;&lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;void&lt;/FONT&gt;&lt;FONT size="2"&gt; &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;__cdecl&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode(); &lt;P&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;int&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; main(&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;int&lt;/FONT&gt;&lt;FONT size="2"&gt; argc, &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;char&lt;/FONT&gt;&lt;FONT size="2"&gt;* argv[])&lt;P&gt;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;TestCode(); &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;return&lt;/FONT&gt;&lt;FONT size="2"&gt; 0;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;</description>
    <pubDate>Fri, 10 Aug 2007 05:20:18 GMT</pubDate>
    <dc:creator>pradeepnatekar</dc:creator>
    <dc:date>2007-08-10T05:20:18Z</dc:date>
    <item>
      <title>c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841429#M59398</link>
      <description>&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;I am using MS VS 6.0 for a c++ application which need to call a dll built with IVF (Version 9.0.2945.2003). The code which I have in C++ and Fortran is given below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;C++:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff" size="2"&gt;#include "stdafx.h"&lt;BR /&gt;#include &lt;IOSTREAM.H&gt;&lt;BR /&gt;extern "C" &lt;BR /&gt; { &lt;BR /&gt;void __cdecl TestCode();&lt;BR /&gt; }&lt;BR /&gt;int main(int argc, char* argv[])&lt;BR /&gt;{&lt;BR /&gt;TestCode();&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/IOSTREAM.H&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;FORTRAN:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff" size="2"&gt;subroutine TestCode&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff" size="2"&gt;!DEC$ ATTRIBUTES DLLEXPORT::TestCode&lt;BR /&gt;!DEC$ ATTRIBUTES C, ALIAS: 'TestCode':: TestCode&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff" size="2"&gt;call MainExp()&lt;BR /&gt;end subroutine TestCode&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;The TestCode.dll and .lib are in path of the C++ exe. Building the project gives following error.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#ff0000" size="2"&gt;Test.obj : error LNK2001: unresolved external symbol _TestCode&lt;BR /&gt;Debug/Test.exe : fatal error LNK1120: 1 unresolved externals&lt;BR /&gt;Error executing link.exe.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;Do I need to change something in vc++ project settings to get it right. Please help.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;Pradeep&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2007 14:03:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841429#M59398</guid>
      <dc:creator>pradeepnatekar</dc:creator>
      <dc:date>2007-08-08T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841430#M59399</link>
      <description>Either add the leading underscore in the ALIAS attribute or, preferably, add the DECORATE attribute as well.&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Aug 2007 15:03:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841430#M59399</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-08-08T15:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841431#M59400</link>
      <description>&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;Steve&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;I have made the changes as follows:&lt;/FONT&gt;&lt;/P&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES DLLEXPORT:: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES C, DECORATE, ALIAS: '_TestCode':: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;!call MainExp()&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;print&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;*, "Say Hello from Fortran"&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;end subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Arial"&gt;Still the linker gives error.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2007 15:28:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841431#M59400</guid>
      <dc:creator>pradeepnatekar</dc:creator>
      <dc:date>2007-08-08T15:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841432#M59401</link>
      <description>I said "either". Don't do both. Either add the underscore or add DECORATE, but both together will give you a symbol with two leading underscores.&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Aug 2007 17:00:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841432#M59401</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-08-08T17:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841433#M59402</link>
      <description>Steve I tried both. Its not working. Do I need to change something in c++ project settings?</description>
      <pubDate>Thu, 09 Aug 2007 05:46:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841433#M59402</guid>
      <dc:creator>pradeepnatekar</dc:creator>
      <dc:date>2007-08-09T05:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841434#M59403</link>
      <description>Are you linking the export library (.lib) created by the Fortran project in the C++ project?&lt;BR /&gt;&lt;BR /&gt;Be sure that you do not do BOTH of the things I mentioned. Use DECORATE and have the ALIAS omit the underscore.&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Aug 2007 15:39:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841434#M59403</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-08-09T15:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: c++ calling fortran dll linker error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841435#M59404</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;IusedDECORATE and ALIAS without the leading underscore. The only thing I forgot to do was to include the .lib in c++ project. Now I have added .lib to roject and kept .lib and .dll in path of c++ exe. It works fine now. Thanks for your help. Final code is as below:&lt;/P&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;---------------------Fortran Code--------------------&lt;/P&gt;
&lt;P&gt;subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES DLLEXPORT:: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES C, DECORATE, ALIAS:'TestCode':: TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;print&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;*, "Say Hello from Fortran"&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;end subroutine&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;#include&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; "stdafx.h"&lt;P&gt;&lt;/P&gt;
&lt;P&gt;------------------C++ code -------------------&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;extern&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; "C" &lt;P&gt;&lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;void&lt;/FONT&gt;&lt;FONT size="2"&gt; &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;__cdecl&lt;/FONT&gt;&lt;FONT size="2"&gt; TestCode(); &lt;P&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;int&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; main(&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;int&lt;/FONT&gt;&lt;FONT size="2"&gt; argc, &lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;char&lt;/FONT&gt;&lt;FONT size="2"&gt;* argv[])&lt;P&gt;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;TestCode(); &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;return&lt;/FONT&gt;&lt;FONT size="2"&gt; 0;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;</description>
      <pubDate>Fri, 10 Aug 2007 05:20:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/c-calling-fortran-dll-linker-error/m-p/841435#M59404</guid>
      <dc:creator>pradeepnatekar</dc:creator>
      <dc:date>2007-08-10T05:20:18Z</dc:date>
    </item>
  </channel>
</rss>

