Linking to MKL DLL : unresolved symbols

Linking to MKL DLL : unresolved symbols

I'm trying to link to the DLL versions of MKL when building my exe. My exe also uses pardiso, so I statically link to mkl_solver.lib, and, per the techinical user notes, I also statically link to mkl_c.lib since mkl_solver.lib references symbols defined in mkl_c.lib. So, currently I'm stuck having to use static linking to mkl_solver.lib since there is no DLL library for using pardiso.

I also, and this is the problem, want to use the DLL versions of BLAS found in MKL 7.0.1 (w_mkl_u_7.0.1.007).

So I put the additional dependency of mkl_c_dll.lib in Project|Properties|Linker|Input..Additional Dependencies. I have the Fortran|External Procedures..Calling Convention set to default (when I set it to C, REFERENCE then I get unresolved symbol _pardiso in a procedure that does not even directly or indirectly reference pardiso!).

I have defined in my source (single file) the DLLIMPORT property of the required BLAS procedures thus

!
MODULE mod_BLAS_real_int
!
PUBLIC
!
! import BLAS through Intel MKL DLLs in mkl_c_dll.lib ( IVF-specific )
!
!
INTERFACE
!
REAL(KIND(1.0D0)) PURE FUNCTION DDOT ( n, dx, incx, dy, incy )
!DEC$ ATTRIBUTES DLLIMPORT :: DDOT
REAL(KIND(1.0D0)), INTENT(IN) :: dx(*), dy(*)
INTEGER, INTENT(IN) :: incx, incy, n
END FUNCTION DDOT
!
SUBROUTINE DGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX, &
BETA, Y, INCY )
!DEC$ ATTRIBUTES DLLIMPORT :: DGEMV
REAL(KIND(1.0D0)), INTENT(IN) :: ALPHA, BETA
INTEGER, INTENT(IN) :: INCX, INCY, LDA, M, N
CHARACTER(1), INTENT(IN) :: TRANS
REAL(KIND(1.0D0)), INTENT(IN) :: A( LDA, * ), X( * )
REAL(KIND(1.0D0)), INTENT(INOUT) :: Y( * )
END SUBROUTINE DGEMV
!
REAL(KIND(1.0D0)) PURE FUNCTION DNRM2 ( N, X, INCX )
!DEC$ ATTRIBUTES DLLIMPORT :: DNRM2
INTEGER, INTENT(IN) :: INCX, N
REAL(KIND(1.0D0)), INTENT(IN) :: X( * )
END FUNCTION DNRM2
!
REAL(KIND(1.0)) PURE FUNCTION SNRM2 ( n, x, incx )
!DEC$ ATTRIBUTES DLLIMPORT :: SNRM2
REAL(KIND(1.0)), INTENT(IN) :: x(*)
INTEGER, INTENT(IN) :: n, incx
END FUNCTION SNRM2
!
END INTERFACE
!
!-------------------------------------------------------------------------------------------------------
!
END MODULE mod_BLAS_real_int
!

The compile builds fine, but I get the following linker errors:

Linking...
Link /OUT:"Release/LoTekFEA.exe" /INCREMENTAL:NO /LIBPATH:"F:Program FilesIntelMKL701ia32lib" /SUBSYSTEM:CONSOLE mkl_c_dll.lib Release/LoTekFEAfa.obj "F:Program FilesIntelMKL701ia32libmkl
_solver.lib" "F:Program FilesIntelMKL701ia32libmkl_c.lib"
IPO Error: unresolved : __imp__DNRM2
Referenced in Release/LoTekFEAfa.obj
IPO Error: unresolved : __imp__DDOT
Referenced in Release/LoTekFEAfa.obj
IPO Error: unresolved : __imp__SNRM2
Referenced in Release/LoTekFEAfa.obj
Release/LoTekFEAfa.obj:warning : locally defined symbol __imp__DGEMV imported
Link: executing 'link'
Microsoft Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/OUT:Release/LoTekFEA.exe
/INCREMENTAL:NO
"/LIBPATH:F:Program FilesIntelMKL701ia32lib"
/SUBSYSTEM:CONSOLE
mkl_c_dll.lib
Release/LoTekFEAfa.obj
"F:Program FilesIntelMKL701ia32libmkl_solver.lib"
"F:Program FilesIntelMKL701ia32libmkl_c.lib"
LoTekFEAfa.obj : warning LNK4217: locally defined symbol _DGEMV imported in function _MOD_ITERATIVE_SOLVERS_EX_mp_GMRESR.J
LoTekFEAfa.obj : error LNK2019: unresolved external symbol __imp__DNRM2 referenced in function _MOD_FORM_EL_M_LIN_EX_mp_FORM_EL_M_LIN.J
LoTekFEAfa.obj : error LNK2019: unresolved external symbol __imp__DDOT referenced in function _MOD_ITERATIVE_SOLVERS_EX_mp_BICGSTAB.J
LoTekFEAfa.obj : error LNK2019: unresolved external symbol __imp__SNRM2 referenced in function _MOD_UTIL_EX_mp_VEC_NORM_V_S.J
Release/LoTekFEA.exe : fatal error LNK1120: 3 unresolved externals

LoTekFEA build failed.

I'm using /Ob2 /QaxN for optimization (default /O2).

Now, for example, "DNRM2"is referenced in several more places than just in FORM_EL_M_LIN, so why not multiple linker errors for the other many referecnces to DNRM2? In fact DNRM2 is not even directly referenced in FORM_EL_M_LIN, the reference is indirect because FORM_EL_M_LIN refernces an overloaded module procedure "vec_norm"

!
MODULE mod_util_ex
USE mod_ircl_intrinsic_types
PRIVATE
PUBLIC :: max_elem_nodes, &
min_elem_nodes, &
g_dof_per_node, &
el_dof_per_node, &
elem_dim, &
shell_name, &
beam_name, &
determinant, &
inv_det_23mat, &
inv_det_mat23, &
nat_nod_ord, &
nod_rst_cord, &
vec_norm, &
error_trap, &
augment, &
OPERATOR(.cross.), &
OPERATOR(.equals.), &
Form_csTrcs, &
iocs_cords, &
spline
!
INTERFACE vec_norm
MODULE PROCEDURE vec_norm_v_s, vec_norm_cm_s, &
vec_norm_v_d, vec_norm_cm_d
END INTERFACE vec_norm

!
INTERFACE OPERAT
OR(.cross.)
MODULE PROCEDURE vcrossw_s, vcrossw_d
END INTERFACE OPERATOR(.cross.)
!
INTERFACE OPERATOR(.equals.)
MODULE PROCEDURE equals_sgl, equals_dbl
END INTERFACE OPERATOR(.equals.)
!
CONTAINS
!
....
!------------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------------
PURE FUNCTION vec_norm_v_s( vec )
USE mod_BLAS_real_int, ONLY : SNRM2
! SNRM2 ( n, x, incx )
IMPLICIT NONE
REAL(SP), INTENT(IN) :: vec(:)
REAL(SP) :: vec_norm_v_s
vec_norm_v_s = SNRM2( SIZE(vec), vec, 1 )
END FUNCTION vec_norm_v_s
!------------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------------
PURE FUNCTION vec_norm_cm_s( arrofvec )
USE mod_BLAS_real_int, ONLY : SNRM2
IMPLICIT NONE
REAL(SP), INTENT(IN) :: arrofvec(:,:)
REAL(SP) :: vec_norm_cm_s(SIZE(arrofvec,2))
!
INTEGER :: n, a
!
n = SIZE(arrofvec,1)
DO a = 1, SIZE(arrofvec,2)
vec_norm_cm_s(a) = SNRM2( n, arrofvec(:,a), 1 )
END DO
END FUNCTION vec_norm_cm_s
!------------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------------
PURE FUNCTION vec_norm_v_d( vec )
USE mod_BLAS_real_int, ONLY : DNRM2
! DNRM2 ( n, x, incx )
IMPLICIT NONE
REAL(DP), INTENT(IN) :: vec(:)
REAL(DP) :: vec_norm_v_d
vec_norm_v_d = DNRM2( SIZE(vec), vec, 1 )
END FUNCTION vec_norm_v_d
!------------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------------
PURE FUNCTION vec_norm_cm_d( arrofvec )
USE mod_BLAS_real_int, ONLY : DNRM2
IMPLICIT NONE
REAL(DP), INTENT(IN) :: arrofvec(:,:)
REAL(DP) :: vec_norm_cm_d(SIZE(arrofvec,2))
!
INTEGER :: n, a
!
n = SIZE(arrofvec,1)
DO a = 1, SIZE(arrofvec,2)
vec_norm_cm_d(a) = DNRM2( n, arrofvec(:,a), 1 )
END DO
END FUNCTION vec_norm_cm_d

...

and even "vec_norm" is referenced in many, many places throughout the source file.

Are the linker errors (seemingly inconsistent IMHO) a result of improper or incomplete specification of, for example

!DEC$ ATTRIBUTES DLLIMPORT :: DNRM2

in "DNRM2"s interface?

Additionally, what's with the linker warning regarding the reference of "DGEMV"?

I will close with the observation that when I remove the DLLIMPORT properties and statically link to the mkl_c.lib for Everything that references Intel MKL that the build succeeds and the program yields correct results from an extensive suite of tests.

Brian Earl Lamm

publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Thanks for the underwhelming response. I will just have to submit issue with Intel.

Again, thanks so much for the underwhelming response Intel.

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya