Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26755 Discussions

Linking .dll files to a FORTRAN 90 program in Microsoft VS community 2015

Vahid_H_
Beginner
617 Views

I have difficulty to Link .dll files to FORTRAN 90 program in Microsoft VS community 2015. Any help would be appreciated. Thank you.

0 Kudos
11 Replies
Steve_Lionel
Black Belt Retired Employee
617 Views

Please explain in more detail what you are trying to do (attaching a ZIP of the buildlog.htm from the failed build would be helpful.)

I hope that you are aware that one does not link to DLLs - instead you link to the export library (.LIB) created when the DLL was built. If you don't have that, you will need to use dynamic loading - a worked example is provided in the Intel Fortran samples as DLL\DynamicLoad.

Vahid_H_
Beginner
617 Views

a

Vahid_H_
Beginner
617 Views

 

Thank you for your response, Steve.

The code is linked to export library as shown in the attached pictures; however, it is not working since the .dd files are missed. My problem is that how can I define the path to .dll files in Fortran. I was successful to run this code by pasting all the required .dll files in the code folder but it is a messy way to do this.  Attached, there is a copy of the code.

 

Steve Lionel (Ret.) wrote:

Please explain in more detail what you are trying to do (attaching a ZIP of the buildlog.htm from the failed build would be helpful.)

I hope that you are aware that one does not link to DLLs - instead you link to the export library (.LIB) created when the DLL was built. If you don't have that, you will need to use dynamic loading - a worked example is provided in the Intel Fortran samples as DLL\DynamicLoad.

Steve_Lionel
Black Belt Retired Employee
617 Views

Windows has rules for how it locates DLLs at run-time - this isn't something you do in Fortran. The order is (if I have this right):

  1. The current directory
  2. The directory containing the EXE
  3. Directories named in the PATH environment variable
  4. The Windows directory
  5. The Windows\System32 directory

Typically people copy DLLs into the same folder as the exe for use when the exe is run.

Vahid_H_
Beginner
617 Views

 

even If the PATH is set to the folder of .dll files, the code gives the same error.

Steve Lionel (Ret.) wrote:

Windows has rules for how it locates DLLs at run-time - this isn't something you do in Fortran. The order is (if I have this right):

  1. The current directory
  2. The directory containing the EXE
  3. Directories named in the PATH environment variable
  4. The Windows directory
  5. The Windows\System32 directory

Typically people copy DLLs into the same folder as the exe for use when the exe is run.

Steve_Lionel
Black Belt Retired Employee
617 Views

So where is libmat.dll? And is it a 32-bit or 64-bit DLL?

Download Dependency Walker . Run it from the command line while in the directory with the EXE and have it open your EXE. Does it show any missing DLLs? (Ignore "delay-load" messages.)

mecej4
Black Belt
617 Views

You need to add the Matlab bin\<arch> directory to PATH before attempting to run the EXE that is produced by linking with libmx.lib and libmat.lib.

Vahid_H_
Beginner
617 Views

 

There are two versions(32&64) of Matlab installed on this computer(64). Dlls are located here "C:\MATLAB_32bits\bin\win32". The result of using Dependency Walker is attached. 

Steve Lionel (Ret.) wrote:

So where is libmat.dll? And is it a 32-bit or 64-bit DLL?

Download Dependency Walker . Run it from the command line while in the directory with the EXE and have it open your EXE. Does it show any missing DLLs? (Ignore "delay-load" messages.)

Vahid_H_
Beginner
617 Views

C:\MATLAB_32bits\bin\; is in the PATH but still doesn't work.

mecej4 wrote:

You need to add the Matlab bin\<arch> directory to PATH before attempting to run the EXE that is produced by linking with libmx.lib and libmat.lib.

mecej4
Black Belt
617 Views

Vahid H. wrote:

C:\MATLAB_32bits\bin\; is in the PATH but still doesn't work.

That path component is incomplete; it should be C:\MATLAB_32bits\bin\win32 .

Vahid_H_
Beginner
617 Views

Sorry, the address is set to C:\MATLAB_32bits\bin\win32 in my system. The address was not written correctly before.

 

mecej4 wrote:

Quote:

Vahid H. wrote:

 

C:\MATLAB_32bits\bin\; is in the PATH but still doesn't work.

 

 

That path component is incomplete; it should be C:\MATLAB_32bits\bin\win32 .

Reply