<?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 mecej4, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954317#M93066</link>
    <description>&lt;P&gt;mecej4,&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;I verified the platform I am compiling against and it is x86 - at least according to the Project Properties Build page and the Platform Target says x86. &amp;nbsp;I still get the same message.&lt;/P&gt;
&lt;P&gt;are there any options the fortran dll needs built with?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Charlie&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2013 14:25:53 GMT</pubDate>
    <dc:creator>Charles_G_2</dc:creator>
    <dc:date>2013-07-22T14:25:53Z</dc:date>
    <item>
      <title>C# calling fortran function errors out with BadImageFormatException</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954314#M93063</link>
      <description>&lt;P&gt;I have been given a fortran dll created by a coworker to use in my c# app. the dll was compiled as 32 bit dll and the function i desire has been exported. i confirmed the export using DUMPBIN /EXPORTS my.dll and the function i want to use is listed.&lt;/P&gt;
&lt;P&gt;When I try to call the function i get an exception: BadImageFormatException - an attempt was made to load a program with an incorrect format.&lt;/P&gt;
&lt;P&gt;My application has been compiled with VS 2010 as 32 bit but I am running on Windows 7 64 bit. Below is my c# code:&lt;/P&gt;
&lt;P&gt;using System;&lt;/P&gt;
&lt;P&gt;namespace FortranTest&lt;BR /&gt;{&lt;BR /&gt;class Program&lt;BR /&gt;{&lt;BR /&gt;static void Main(string[] args)&lt;BR /&gt;{&lt;BR /&gt;double p = (double)2500.0;&lt;BR /&gt;double t = (double)950.0;&lt;BR /&gt;short b = (short)1;&lt;/P&gt;
&lt;P&gt;float h = FortranWrapper.ENTPT(ref p, ref t, ref b);&lt;BR /&gt;} &lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;using System;&lt;BR /&gt;using System.Runtime.InteropServices;&lt;/P&gt;
&lt;P&gt;namespace FortranTest&lt;BR /&gt;{&lt;BR /&gt;class FortranWrapper&lt;BR /&gt;{&lt;BR /&gt;[DllImport("My.dll", CallingConvention = CallingConvention.Cdecl)]&lt;BR /&gt;public static extern float ENTPT(ref double Pa, ref double Tx, ref short b);&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;I did NOT install the Fortran development environment but the runtime libs located here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://software.intel.com/en-us/articles/redistributable-libraries-for-the-intel-c-and-visual-fortran-composer-xe-for-windows" target="_blank"&gt;http://software.intel.com/en-us/articles/redistributable-libraries-for-the-intel-c-and-visual-fortran-composer-xe-for-windows&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I have used the DependencyWalker to verify I have the required files and it looks pretty good. I am only mission 2 files: GPSVC.DLL and IESHIMS.DLL&lt;BR /&gt;but these are missing for applications that work so i don't think it is a problem.&lt;/P&gt;
&lt;P&gt;I know very little about fortran but need help getting this working. its probably something stupid that i am doing but i cant find it.&lt;/P&gt;
&lt;P&gt;Sorry for posting again....The first post didn't show up so I am reposting.&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help!!&lt;/P&gt;
&lt;P&gt;charlie&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:05:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954314#M93063</guid>
      <dc:creator>Charles_G_2</dc:creator>
      <dc:date>2013-07-18T21:05:41Z</dc:date>
    </item>
    <item>
      <title>Provide the /platform:x86</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954315#M93064</link>
      <description>&lt;P&gt;Provide the&lt;STRONG&gt; /platform:x86&lt;/STRONG&gt; option to the C# compiler.&lt;/P&gt;
&lt;P&gt;Alternatively, have your coworker build you a 64-bit DLL.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:22:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954315#M93064</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2013-07-18T21:22:00Z</dc:date>
    </item>
    <item>
      <title>mecej4,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954316#M93065</link>
      <description>&lt;P&gt;mecej4,&lt;/P&gt;
&lt;P&gt;Thank you for your help. &amp;nbsp; I am targeting the x86 platform but still receiving the error message.&lt;/P&gt;
&lt;P&gt;I have targeted the x86 framework by looking at the project build properties and setting Platform target to be x86.&lt;/P&gt;
&lt;P&gt;If that is incorrect or if you have other ideas let me know?&lt;/P&gt;
&lt;P&gt;Does the person creating the fortran dll have to do anything special while compiling?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Charlie&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2013 12:20:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954316#M93065</guid>
      <dc:creator>Charles_G_2</dc:creator>
      <dc:date>2013-07-22T12:20:33Z</dc:date>
    </item>
    <item>
      <title>mecej4,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954317#M93066</link>
      <description>&lt;P&gt;mecej4,&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;I verified the platform I am compiling against and it is x86 - at least according to the Project Properties Build page and the Platform Target says x86. &amp;nbsp;I still get the same message.&lt;/P&gt;
&lt;P&gt;are there any options the fortran dll needs built with?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Charlie&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2013 14:25:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954317#M93066</guid>
      <dc:creator>Charles_G_2</dc:creator>
      <dc:date>2013-07-22T14:25:53Z</dc:date>
    </item>
    <item>
      <title>Because of the plethora of</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954318#M93067</link>
      <description>&lt;P&gt;Because of the plethora of options and settings available in the IDE, it is difficult to pinpoint why the build error occurred unless you provide the log of the build.&lt;/P&gt;
&lt;P&gt;You may find it useful to look at a recent thread on a similar problem:&amp;nbsp;http://software.intel.com/en-us/forums/topic/391002 . To build the example given there using 32-bit compilers on 64-bit Windows the commands are&lt;/P&gt;
&lt;P&gt;[bash]&lt;/P&gt;
&lt;P&gt;ifort /LD /Od cbk.f90 /FeCallbackTest.dll&lt;BR /&gt;csc cbk.cs /platform:x86&lt;/P&gt;
&lt;P&gt;[/bash]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could build and run that example, and then attempt to duplicate the build using the VS IDE.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2013 15:23:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954318#M93067</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2013-07-22T15:23:00Z</dc:date>
    </item>
    <item>
      <title>No, the Fortran DLL doesn't</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954319#M93068</link>
      <description>&lt;P&gt;No, the Fortran DLL doesn't need specific options.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2013 15:25:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954319#M93068</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-07-22T15:25:59Z</dc:date>
    </item>
    <item>
      <title>Well, I got it working but I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954320#M93069</link>
      <description>&lt;P&gt;Well, I got it working but I am not able to determine the exact problem or what fixed it.&lt;/P&gt;
&lt;P&gt;I found out that the data types in the FortranWrapper should have been Single instead of Double but I don't think that was the initial problem.&lt;/P&gt;
&lt;P&gt;It started working when I clicked the "Allow UnSafe Code". &amp;nbsp;However, I then unchecked it and it still ran.&lt;/P&gt;
&lt;P&gt;If I am able to narrow down the problem, i will post more info.&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2013 21:08:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-calling-fortran-function-errors-out-with/m-p/954320#M93069</guid>
      <dc:creator>Charles_G_2</dc:creator>
      <dc:date>2013-07-23T21:08:56Z</dc:date>
    </item>
  </channel>
</rss>

