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
Beginner
1,218 Views

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 Kudos
1 Solution
Steven_L_Intel1
Employee
1,218 Views

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

View solution in original post

0 Kudos
7 Replies
mecej4
Honored Contributor III
1,218 Views

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.

 

0 Kudos
Steven_L_Intel1
Employee
1,219 Views

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

0 Kudos
FortranFan
Honored Contributor III
1,218 Views

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.

0 Kudos
mecej4
Honored Contributor III
1,218 Views

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.

0 Kudos
Steven_L_Intel1
Employee
1,218 Views

dforrt.dll will also need msvcrt.dll.

0 Kudos
FortranFan
Honored Contributor III
1,218 Views

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.  

0 Kudos
Steve1
Beginner
1,218 Views

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)

0 Kudos
Reply