Home > Archive > Fortran > October 2006 > Linking to a DLL in Intel Visual Fortran
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Linking to a DLL in Intel Visual Fortran
|
|
| stephen 2006-09-04, 7:00 pm |
|
Background:
I am using the Intel FORTRAN compilter (v8.x) under microsoft visual
studio .NET, of course on a PC running XP.
I created a dynamic link library project. I then imported from netlib
the LAPACK fortran libray into this project, and successfully compiled
it. This of course generates .lib and .dll files. In my case, they
are called LAPACK.lib and LAPACK.dll
Problem:
Now, I am trying to link to the LAPACK.dll in another project - so far
without any success. The linker tells me that it cannot find the
LAPACK routines that I am linking to. I have tried the following:
In "Project - Properties - Configuration Properties - Linker -
General", I specify in the box "Additional Library Directories" the
path name of the LAPACK.lib and .dll files.
I also tried "Project - Properties - Configuration Properties - Fortran
- General" in the box "Additional Include Directories" to add the
patch to the LAPACK.lib directory.
I have also simply copied the LAPACK.lib and LAPACK.dll files directly
into my project directory. This still has not worked.
Can anyone give any advice as to how I should properly link to the
LAPACK dynamic link library that I've created? Thanks!
| |
| Craig Powers 2006-09-04, 7:00 pm |
| stephen wrote:
> Background:
> I am using the Intel FORTRAN compilter (v8.x) under microsoft visual
> studio .NET, of course on a PC running XP.
>
> I created a dynamic link library project. I then imported from netlib
> the LAPACK fortran libray into this project, and successfully compiled
> it. This of course generates .lib and .dll files. In my case, they
> are called LAPACK.lib and LAPACK.dll
>
>
> Problem:
> Now, I am trying to link to the LAPACK.dll in another project - so far
> without any success. The linker tells me that it cannot find the
> LAPACK routines that I am linking to. I have tried the following:
>
> In "Project - Properties - Configuration Properties - Linker -
> General", I specify in the box "Additional Library Directories" the
> path name of the LAPACK.lib and .dll files.
>
> I also tried "Project - Properties - Configuration Properties - Fortran
> - General" in the box "Additional Include Directories" to add the
> patch to the LAPACK.lib directory.
>
> I have also simply copied the LAPACK.lib and LAPACK.dll files directly
> into my project directory. This still has not worked.
>
> Can anyone give any advice as to how I should properly link to the
> LAPACK dynamic link library that I've created? Thanks!
>
Add lapack.lib to the list of library files referenced by the linker --
I don't remember what the exact title for the text box is. There may
already be a list of stuff like kernel32.lib, etc. there, in which case
you can add lapack.lib onto the end of the list.
(At least in C and C++, as I recall VC has a pragma that allows you to
insert a library reference directly into a source file -- there may be
something similar in the ifort-specific directives, although I'm not
sure that really gains you anything.)
| |
| stephen 2006-09-04, 7:00 pm |
| Craig Powers wrote:
> Add lapack.lib to the list of library files referenced by the linker --
> I don't remember what the exact title for the text box is. There may
> already be a list of stuff like kernel32.lib, etc. there, in which case
> you can add lapack.lib onto the end of the list.
>
>
> (At least in C and C++, as I recall VC has a pragma that allows you to
> insert a library reference directly into a source file -- there may be
> something similar in the ifort-specific directives, although I'm not
> sure that really gains you anything.)
This is exactly what I have been trying to find. Unfortunatley, I've
gone through all the project properties options, and have not found an
existing list (though, you would think that there would be a standard
one there) to modify.
I am either miss-understanding what is there, or still missing the boat
on how to include these lib files.
| |
| beliavsky@aol.com 2006-09-04, 7:00 pm |
| stephen wrote:
> Background:
> I am using the Intel FORTRAN compilter (v8.x) under microsoft visual
> studio .NET, of course on a PC running XP.
The best place to ask this question is the Intel Visual Fortran forum
at
http://softwareforums.intel.com/ISN.../ShowForum.aspx
..
| |
| Jugoslav Dujic 2006-09-05, 3:59 am |
| stephen wrote:
| Craig Powers wrote:
|| Add lapack.lib to the list of library files referenced by the linker --
|| I don't remember what the exact title for the text box is. There may
|| already be a list of stuff like kernel32.lib, etc. there, in which case
|| you can add lapack.lib onto the end of the list.
||
||
|| (At least in C and C++, as I recall VC has a pragma that allows you to
|| insert a library reference directly into a source file -- there may be
|| something similar in the ifort-specific directives, although I'm not
|| sure that really gains you anything.)
|
| This is exactly what I have been trying to find. Unfortunatley, I've
| gone through all the project properties options, and have not found an
| existing list (though, you would think that there would be a standard
| one there) to modify.
|
| I am either miss-understanding what is there, or still missing the boat
| on how to include these lib files.
It's Linker/Input/Additional dependencies. Adding the library path to
the dir-list only saves you from typing the full path in that box.
(NB: If I recall correctly, the copy of the .lib within the solution
folder will be searched for before the one in "additional library
dependencies"; be aware in the case you change the library.)
--
Jugoslav
___________
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.
| |
|
|
stephen wrote:
....
> I am either miss-understanding what is there, or still missing the boat
> on how to include these lib files.
So the post title should be "Linking to a Lib..." not DLL? Yet you
described building a .DLL project iiu in the original post...
I'm by the request vis a vis the concentration on the linker
and .lib files...my first thought was the problem is one is trying to
force static linking to a dynamic link???
| |
| Craig Powers 2006-09-05, 7:00 pm |
| dpb wrote:
> stephen wrote:
> ...
>
>
> So the post title should be "Linking to a Lib..." not DLL? Yet you
> described building a .DLL project iiu in the original post...
>
> I'm by the request vis a vis the concentration on the linker
> and .lib files...my first thought was the problem is one is trying to
> force static linking to a dynamic link???
When you build a DLL, you also get a .lib file that you can link
against, which will a) tell the linker that the functions are imported
from the DLL, and b) automagically take care of loading the DLL when the
program starts. The OP would like to link a program that uses exported
functions from the DLL. His description of the problem is perhaps a
little imprecise, but there was plenty enough detail for folks who are
familiar with that build system to know what was going on.
I believe that there are some compilers (don't know if any Fortran
compilers fall into this category) that can extract import information
from the DLL without the .lib file. I presume that's not something that
can be done with ifort, though... I don't recall that it was possible
with DVF.
| |
| Jugoslav Dujic 2006-09-06, 7:59 am |
| Craig Powers wrote:
| dpb wrote:
|| stephen wrote:
<snip>
| I believe that there are some compilers (don't know if any Fortran
| compilers fall into this category) that can extract import information
| from the DLL without the .lib file. I presume that's not something that
| can be done with ifort, though... I don't recall that it was possible
| with DVF.
AFAIK (not that I tried) It's possible with some manual twiddling:
1) find the list of exports using dumpbin.exe or depends.exe
2) copy the list into a textual .def file in appropriate format
3) make the .lib with LIB /def
Of course, there's still "dynamic binding" (resolving references in
run-time instead of link-time), but it involves non-standard extension
(ifort/VF Cray pointers to procedures) and non-portable APIs
(LoadLibrary/GetProcAddress).
--
Jugoslav
___________
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.
| |
| Craig Powers 2006-09-06, 7:01 pm |
| Jugoslav Dujic wrote:
> Craig Powers wrote:
> | dpb wrote:
> || stephen wrote:
> <snip>
> | I believe that there are some compilers (don't know if any Fortran
> | compilers fall into this category) that can extract import information
> | from the DLL without the .lib file. I presume that's not something that
> | can be done with ifort, though... I don't recall that it was possible
> | with DVF.
>
> AFAIK (not that I tried) It's possible with some manual twiddling:
> 1) find the list of exports using dumpbin.exe or depends.exe
> 2) copy the list into a textual .def file in appropriate format
> 3) make the .lib with LIB /def
I'm referring to compilers doing all of the above automagically, so that
you reference the dll and they figure out how to link to it. I'm pretty
sure there is at least one C++ compiler that will do that.
(And then there's VB, where you give it the procedure interface and tell
it which dll to use, and it does run-time dynamic access, but that's
more like the stuff that I elided about using procedure pointers and
LoadLibrary/GetProcAddress...)
| |
|
|
|
|
|