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

How to link with additional dll files?

xianyao-chen
Beginner
1,193 Views
Dear all,

I trid to compile a fortran code which need use a subroutine available in another matlab libmat.dll file, I tried following command line

f90 test.f90 /libs:dll

but it always show error LNK2001: unresolved external symbol _MATOPEN@16.
This .dll file is really in path, can any one help me?

Thanks a lot

Xianyao Chen
0 Kudos
4 Replies
stober123
Beginner
1,193 Views
Xianyao Chen,
Your compile-link command "f90 test.f90 /libs:dll" only specifies that standard FORTRAN libraries of the dll type (as opposed to static) are to be used.
It does not tell the linker where to find the matlab routine library.
There are two possibilities to make this work:
1. add the proper matlab library (?.lib) file to the command line. This assumesmatlab provides this library. Note ----this is a .lib file not a .dll file
2. If matlab does not provide the library, you will need to create an interface block in your routinefor allthe matlab subroutines youneed to access. Then you will have to add some code to load the matlab dll and get the address of the matlab routine you wish to use. See LOADLIBRARY(), and GETPROCADDRESS()
Good Luck
0 Kudos
Steven_L_Intel1
Employee
1,193 Views
The problem is that a DLL isn't something you can link to. What you need to specify instead is the export library (.lib) created when the DLL was built. The DLL is looked for only at run-time.
0 Kudos
garyscott
Beginner
1,193 Views

Hi,

While most linkers don't support it, there are linkers available that do not require an import library. They derive the information they need from the DLL. I forget which, but I was just reading about it last week.

0 Kudos
Steven_L_Intel1
Employee
1,193 Views
We do have a tool that will generate an import library if you don't have one. There may indeed be linkers that will extract the necessary info from the DLL, but the MS linker we use doesn't.
0 Kudos
Reply