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

Dynamic Linking Dll-- File Size is Still Too Big

Ngu_Soon_Hui
Beginner
1,159 Views

I am testing a BLAS example here by trying to create a simple exe with dynamic linking tousing BLAS library. This is my code

program dot_main
real x(10), y(10), sdot, res
integer n, incx, incy, i
external sdot
n = 5
incx = 2
incy = 1
do i = 1, 10
x(i) = 2.0e0
y(i) = 1.0e0
end do
res = sdot (n, x, incx, y, incy)
print*, 'SDOT=',res
end

In order to do sequential, dynamic linking I specify the following in Config Properties->Linker->Input->Additional Dependencies:

mkl_sequential_dll.lib mkl_core_dll.lib mkl_intel_c_dll.lib

The output I produced ("blasexample.exe") is 931 kb, and I can run the exe without all the mkl libraries presented in the exe folder. I think what I did is static linking, not dynamic linking. What did I do wrong?

Edit:

I tried the following command line ( yes, it's command line not through GUI) , the same problem persists:

ifort blasexample.F90 mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,159 Views
You need to specify DLL linking to the Fortran run-time DLLs. In the Fortran project properties, select Libraries and set Use Run-Time Library to "Multithreaded DLL".

View solution in original post

0 Kudos
4 Replies
Ngu_Soon_Hui
Beginner
1,159 Views

This is my vfproj file:

0 Kudos
Steven_L_Intel1
Employee
1,160 Views
You need to specify DLL linking to the Fortran run-time DLLs. In the Fortran project properties, select Libraries and set Use Run-Time Library to "Multithreaded DLL".
0 Kudos
Ngu_Soon_Hui
Beginner
1,159 Views

Thanks for your suggestion. After I implement it, the size reduce from 0.9 MB to 80kB. So obviously the library is not fully linked in.

However, in theabsenceof the mkl libraries in the same directory as the exe, I expect the exe couldn't run because of missing dependencies. But from what I found this is not so; the exe can still run even though all the mkl libraries are missing. I tested this on the development machine by copied the exe to other directories.

Any ideas?

0 Kudos
Steven_L_Intel1
Employee
1,159 Views
I don't fully understand the second paragraph. On the development system, the path to the MKL DLLs is added to PATH by the compiler install. If you are going to run the program on a system that does not have Intel Visual Fortran installed, you will need to copy the DLLs used and either put them in the same directory as the EXE or somewhere in PATH. You will also need the Microsoft Visual C++ redistributables, for the same version of Visual Studio you are using, installed on the target system.
0 Kudos
Reply