Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

FORTRAN DLL called from VB.net

Steve1
ビギナー
1,251件の閲覧回数

I have Compaq Fortran running on a Windows XP machine where I can compile a DLL from Fortran code. I then call this DLL from VB 6 and VB.net without problems. I include dforrt.dll in the directory where the VB project exists.

Below I created a very simple Intel Fortran DLL, which when I try to call from VB.net I get an error message that the DLL cannot be found.

Could you please tell me what I would need to do in order to create a Fortran DLL that can be called from VB.net?

Note: I am a novice programmer.

     subroutine TEST(cal,outp)    

!DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'TEST'::TEST

       implicit double precision (a-h,o-z)

      implicit integer (i-n)

         outp=dexp(cal)

      RETURN

      END 

0 件の賞賛
1 解決策
Steven_L_Intel1
従業員
1,251件の閲覧回数

He's using CVF. I think the command would be:

df /dll fdll.f90

If the Fortran DLL was not going to be called from Fortran, you could link statically and eliminate the need for dforrt,dll:

df /libs:static /dll fdll.f90

We weren't shown how the routine is declared in VB6, but I'll comment that VB will say "DLL not found" for ANY kind of error it gets loading the DLL

元の投稿で解決策を見る

7 返答(返信)
mecej4
名誉コントリビューター III
1,251件の閲覧回数

Try this inside an IFort command window:

  • Build the DLL, using the command ifort /LD fdll.f90 
  • Build the VB program, using the command vbc vbpgm.bas /platform:x86

This also works for x64 if you leave out the platform option in the second command.

 

Steven_L_Intel1
従業員
1,252件の閲覧回数

He's using CVF. I think the command would be:

df /dll fdll.f90

If the Fortran DLL was not going to be called from Fortran, you could link statically and eliminate the need for dforrt,dll:

df /libs:static /dll fdll.f90

We weren't shown how the routine is declared in VB6, but I'll comment that VB will say "DLL not found" for ANY kind of error it gets loading the DLL

FortranFan
名誉コントリビューター III
1,251件の閲覧回数

Steve wrote:

I have Compaq Fortran running on a Windows XP machine where I can compile a DLL from Fortran code. I then call this DLL from VB 6 and VB.net without problems. I include dforrt.dll in the directory where the VB project exists.

Below I created a very simple Intel Fortran DLL, which when I try to call from VB.net I get an error message that the DLL cannot be found.

Could you please tell me what I would need to do in order to create a Fortran DLL that can be called from VB.net?

...

"DLL not found" errors are very often due to some DLL dependencies that are missing on the path.  In your case, you may have run-time dependencies (similar to dforrt.dll with Compaq Fortran) for which you may need to take extra steps.  Take a look at these topics: https://software.intel.com/en-us/forums/topic/275632, https://software.intel.com/en-us/forums/topic/533439, and https://software.intel.com/en-us/forums/topic/506625.

mecej4
名誉コントリビューター III
1,251件の閲覧回数

Steve Lionel (Intel) wrote:
He's using CVF. 

He was using CVF without problems, and is now trying the same with IFort, but has problems.

Steven_L_Intel1
従業員
1,251件の閲覧回数

dforrt.dll will also need msvcrt.dll.

FortranFan
名誉コントリビューター III
1,251件の閲覧回数

Steve wrote:

..

Below I created a very simple Intel Fortran DLL, which when I try to call from VB.net I get an error message that the DLL cannot be found.

Could you please tell me what I would need to do in order to create a Fortran DLL that can be called from VB.net?

..

Steve (OP on this topic),

Do you have Microsoft Visual Studio, something other than the Express edition or the shell?  If so, you can also take a look at a fully-worked out example of a VB .NET program calling a Fortran DLL in Quote #2 at this topic: https://software.intel.com/en-us/forums/topic/509148.  

Steve1
ビギナー
1,251件の閲覧回数

Thank you to Steve, mecej4, and FortranFan. As I said, I am a novice, but with your various comments/help I have resolved my problej. I have used Visual Studio 2005 and have used the library Debug Multithreaded (/libs:static /threads /dbglibs)

返信