0

I'm tryng to figure out how to use a module of a DLL library in a fortran project, still don't know how.

When I read different discussions concerning this, they all talk about using the .lib generated when the DLL was built,

Isn't a DLL a Library (like a .lib) but shared. why do we need the .lib ?

tsumey
  • 63
  • 1
  • 11
  • Why have you tried in the first place? Have you link your program to the DLL and not guetting it to work? What is the error message you are getting? Your question seems vague and my interpretation is that instead of jumping in and trying thing, you are trying to find a solution to a problem you do not have. – innoSPG Aug 23 '16 at 13:17
  • 1
    @innoSPG Hi! i've tried [this](http://stackoverflow.com/questions/39096883/how-can-i-link-a-dll-to-fortran-visual-studio) – tsumey Aug 23 '16 at 13:22
  • The name of a exported function is often different from the identifier that is used in a program. Not so true for Fortran afaik, definitely true in languages like C and C++ and operating system libraries. Name decoration (aka name mangling) is a very common linker hack. Exporting by ordinal instead of name is another example. The .lib file connects the program symbol to the export name and ordinal and the linker needs it to embed the correct import table entry. – Hans Passant Aug 23 '16 at 13:22
  • @innoSPG I'm not an IT guy I barely understand what a Library is,I did not understand much in what you said – tsumey Aug 23 '16 at 13:27
  • @innoSPG i opened the .lib file and it's using 1`_` , anyway, do you know how to compile a fortran program using some DLLs in Windows with ifort (i wanna try compiling without using VISUAL STUDIO) – tsumey Aug 23 '16 at 14:00
  • @tsumey, no offense. Just checking if you actually tried out something, and you showed that you tried. I am not familliar with visual studio. What I suggest is that you check if the underscoring options are consistent between the creation of the dll and the executable. Fortran has the option to add underscore to the name of subroutines and there are compiling options to control it. There can be 0, 1 or 2 `_` added (possibly more). Your test program is compiled to add 1 `_`, make sure that the dll also has 1 `_` – innoSPG Aug 23 '16 at 14:00
  • @innoSPG I checked the lib file and it's ysing only one `_`, I think of trying to compile without using Visual studio. how do i do that in Windows with ifort ? – tsumey Aug 23 '16 at 14:02
  • The problem might be that the dll is not in the lib path at runtime. with linux systems, there is an environmental variable `LD_LIBRARY_PATH` that tells the system where to find dynamic libraries (DLL on windows). You can use the command terminal to compile your prog. basically, you will type commands to do what your IDE is doing under the hood. Not being a windows user, I do not have more details. – innoSPG Aug 23 '16 at 15:55
  • This question (such that it is) reflects the same confusion as in the linked question around the roles that import libraries and DLL's have on Windows. *DLL's on Windows are not linker inputs*, the linker input for executables that are to reference a DLL through load time dynamic linking is [usually] the import library that was generated when the DLL was built. DLL file -> for consumption by the operating system loader, LIB file -> for consumption by the linker. – IanH Aug 23 '16 at 23:02

0 Answers0