Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How to link a dll file

cria_ro
Beginner
4,134 Views
Hello,

I am trying to use the fftw libray under windows. I got a bunch of files libfftw3-3.def and libfftw3-3.dll. How do I compile my code so that it will link to this libraries? Thanks in advance.

The command: >ifort /libs:dll OneD.f libfftw3-3.def libfftw3-3.dll

gives error:

unrecognized surce type libfftw3-3.dll


libfftw3-3.dll : fatal error LNK1107: invalid or corrupt file:

Best regards,

Cristian
0 Kudos
11 Replies
Steven_L_Intel1
Employee
4,134 Views
A .dll is not something you can link to. Usually what you link against is the "export library" (a .lib) that is created as a side-effect of building the DLL. The .def file can be an alternative, so try just leaving the .dll off of the command line and see if that helps.
0 Kudos
cria_ro
Beginner
4,134 Views
I tried all the possible combiantions with .dll or/and .def in the compiling command but it does not work.
What about the visual tools? If I make a project, can I specifiy there to link to my library?

Cristian
0 Kudos
Steven_L_Intel1
Employee
4,134 Views
If you can't get it to work from the command line, you won't do better in Visual Studio.

Where did you get this fftw library? Does it include a .lib?
0 Kudos
cria_ro
Beginner
4,134 Views
If you can't get it to work from the command line, you won't do better in Visual Studio.

Where did you get this fftw library? Does it include a .lib?
Hello,

I downloaded from http://fftw.org/install/windows.html. It contains only .def and .dll files. Th installation manual says:

You should be able to call them from any compiler. In order to link to these .dll files from Visual C++, you need to
create .lib "import libraries" for them, and can do so with the "lib" command that comes with VC++. In particular, run:
lib /machine:i386 /def:libfftw3-3.def
lib /machine:i386 /def:libfftw3f-3.def
lib /machine:i386 /def:libfftw3l-3.def

Unfortunately when I execute lib from the command line I get error file not found.

Cristian

0 Kudos
Steven_L_Intel1
Employee
4,134 Views
Use Start > All Programs > Intel Software Development Tools > Intel Fortran Compiler x.x > Build Environment for applications on IA-32. This will give you a command environment that will define "lib". Make sure you have set default (cd) to the folder containing the .def file.
0 Kudos
cria_ro
Beginner
4,134 Views
Use Start > All Programs > Intel Software Development Tools > Intel Fortran Compiler x.x > Build Environment for applications on IA-32. This will give you a command environment that will define "lib". Make sure you have set default (cd) to the folder containing the .def file.
Hello,

Thank you for your instructions. It did something.

D:fftw-3.2-dll>lib /machine:i386 /def
Microsoft Library Manager Version
Copyright (C) Microsoft Corporation.

Creating library libfftw3-3.lib and and object libfftw3f-3.exp

Now what do I do to compile my codes?

Cristian
0 Kudos
Steven_L_Intel1
Employee
4,134 Views
Add the .lib to your ifort line that links the application.
0 Kudos
cria_ro
Beginner
4,134 Views
Add the .lib to your ifort line that links the application.

I appologize, but could you give me an example of how should I compile the code if it has the dependencies in an external libray?

Cristian
0 Kudos
Steven_L_Intel1
Employee
4,134 Views
ifort yourcode.f90 extlib.lib
0 Kudos
Jugoslav_Dujic
Valued Contributor II
4,134 Views
A .dll is not something you can link to. Usually what you link against is the "export library" (a .lib) that is created as a side-effect of building the DLL. The .def file can be an alternative, so try just leaving the .dll off of the command line and see if that helps.

It would be nice if the compiler driver would invoke LIB automagically when it sees a .def file on its linker command line...
0 Kudos
cria_ro
Beginner
4,134 Views
Quoting - Jugoslav Dujic
A .dll is not something you can link to. Usually what you link against is the "export library" (a .lib) that is created as a side-effect of building the DLL. The .def file can be an alternative, so try just leaving the .dll off of the command line and see if that helps.

It would be nice if the compiler driver would invoke LIB automagically when it sees a .def file on its linker command line...
It would be nice if I could just make it work.
0 Kudos
Reply