Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

call a DLL from Fortran

Hi there,

to call a DLL from another Fortran DLL in another topic Steve Lionel (Intel) wrote that there is an example from Intel, but I can't find.

Is someone able to help me?

Olaf

 

0 Kudos
14 Replies
Highlighted
Retired Employee
9 Views

If you have the .lib that was

If you have the .lib that was generated when the DLL to be called was built, just add that .lib to your project, As long as both DLLs can be found by Windows where it looks for them (location of the EXE or in a folder named in the PATH environment variable), that's all you have to do.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner
9 Views

Hi Steve,

 

Hi Steve,

I have a DLL without the lib from a third provider, but I know about the entry points. How can I deal that?

Olaf

0 Kudos
Highlighted
Black Belt
9 Views

Making an import library from

Making an import library from a DLL can be performed using the following steps and the Visual Studio tools that are installed along with Intel compilers.

  1. Run dumpbin /exports <mydll.dll> > mydll.def OR, if you already know the list of names to be used, put that list into mydll.def.
  2. Edit mydll.def and follow the guidelines at https://msdn.microsoft.com/en-us/library/28d6s79h.aspx .
  3. lib /machine:i386 /def:mydll.def

After you have done these steps, you should have the import library mydll.lib, which you can link with your projects that will use the DLL.​

0 Kudos
Highlighted
Beginner
9 Views

Hi Steve,

Hi Steve,

thank you very much.

And is that possible without an DEF-FILE (with somewhat like !DEC$ATTRIBUTES)?

Olaf

0 Kudos
Highlighted
Beginner
9 Views

Hi Steve,

Hi Steve, I 've done as you first proposed, just adding to the project (with an own made dll - just drag and drop the lib-File to the project). But it dosn't work. VS dosn't recognize the function in the dll. How I call it? Do you have an example? Maybe I forgot something. Olaf
0 Kudos
Highlighted
Retired Employee
9 Views

You may have the name of the

You may have the name of the entry point incorrect.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor II
9 Views

Did you do this?

Did you do this?

dumpbin /exports mydll.dll > mydll.def

0 Kudos
Highlighted
Beginner
9 Views

Hi Steve, hi all,

Hi Steve, hi all,

sorry for my late answer. I had a business trip. The name of my function is correct, I think.

Attached is the Dependency Walker output for my function. I call it x=os_min( ...)

Next I like to try dumpbin.exe. How I have to do that? In DOS? And ok, if nessary I try the DEF-File.

Regards

Olaf

By the way I work with Visual Studio 2017 Version 15.7.5 and Intel Parallel XE 2018 Update 3 Composer Edition for Fortran.

0 Kudos
Highlighted
Retired Employee
9 Views

The @88 means that it is a

The @88 means that it is a STDCALL procedure. Try adding this in the procedure where you call it:

!DEC$ ATTRIBUTES STDCALL, REFERENCE :: OS_MIN

That there are 22 arguments means that it's likely you will need something more to pass the arguments correctly. How is os_min declared in the source for the DLL? I want to see the procedure declaration and the declarations of all its arguments.

I note that the routine name is lowercase, which means it wasn't built with default options in any Fortran compiler.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner
9 Views

No, that aare 11 arguments,

No, that are 11 arguments, because they are double precision.

After I adding your phrase, I have this:

error #6406: Conflicting attributes or multiple declaration of name.   [OS_MIN]       

 

and if I delete the convention double precision :: os_min there is this:

error #6404: This name does not have a type, and must have an explicit type.   [OS_MIN]

 

regards

 

Olaf

 

 

 

0 Kudos
Highlighted
Retired Employee
9 Views

If the arguments are double

If the arguments are double precision, then remove ", REFERENCE" from the ATTRIBUTES line. Do you have another directive naming OS_MIN? You do also need a type declaration, as it would seem you have IMPLICIT NONE.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner
9 Views

Hi Steve,

Hi Steve,

 

now it works!!!!! Thank you very very much.

 

Olaf

0 Kudos
Highlighted
Beginner
9 Views

Hi Steve

Hi Steve

May I ask you some an advice to load rc.exe because it is not present on my PC.

My environment is VS2015 + parallel_studio_xe_2015_update6_online_setup.exe (for FORTRAN).

I need that to call a DLL Fortranin XExcel Office365 x64.

Thks in advance for your help.

Dr O.

 

0 Kudos
Highlighted
Retired Employee
9 Views

rc.exe is part of VS2015's C+

rc.exe is part of VS2015's C++ support. Make sure you followed the steps in https://software.intel.com/en-us/articles/installing-visual-studio-2015-for-use-with-intel-compilers

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos