Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6981 Discussions

Dynamic linking works but static linking fails

Sangamesh_B_
Beginner
295 Views
Hi,

With Intel MKL-10.0.5.025 and ifort-10.1.008, when static linking is used(Sequntial linking, link line is: $(MKLPATH)/libmkl_scalapack_lp64.a $(MKLPATH)/libmkl_solver_lp64_sequential.a -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_sequential.a $(MKLPATH)/libmkl_core.a $(MKLPATH)/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread)

the compilation fails with following error:

/opt/mpi/openmpi/1.3.3/intel/bin/mpif90 -I/opt/libs/netcdf/4.0.1/intel/include -o transiesta \
automatic_cell.o atom_options.o arw.o atomlwf.o bands.o basis_enthalpy.o bessph.o bonds.o born_charge.o m_ts_aux_rout.o m_ts_kpoints.o m_ts_io.o m_ts_scattering.o m_ts_contour.o m_ts_electrode.o m_ts_in_siesta.o libfdf.a \
libmpi_f90.a \
dc_lapack.a liblapack.a libblas.a `FoX/FoX-config --libs --wcml` /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_scalapack_lp64.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_solver_lp64_sequential.a -Wl,--start-group /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_intel_lp64.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_sequential.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread /opt/libs/netcdf/4.0.1/intel/lib/libnetcdf.a
/opt/intel/fce/10.1.008/lib/libimf.so: warning: warning: feupdateenv is not implemented and will always fail
/opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a(zgesv.o): In function `mkl_lapack_zgesv':
__tmp_zgesv.f:(.text+0xbf): undefined reference to `mkl_lapack_zgetrf'
/opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a(zgetrs.o): In function `mkl_lapack_zgetrs':
__tmp_zgetrs.f:(.text+0x1fe): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x27f): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x30b): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x386): undefined reference to `mkl_blas_ztrsm'

But if the same link line is added with dynamic libraries, then it compiles successfully.

MKLPRL=-L$(MKLPATH) -lmkl_lapack -lmkl_core $(MKLPATH)/libmkl_scalapack_lp64.a $(MKLPATH)/libmkl_solver_lp64_sequential.a -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_sequential.a $(MKLPATH)/libmkl_core.a $(MKLPATH)/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread

Why so?

Please justify am I doing anything wrong? or its a problem with static library?

Thank you
0 Kudos
1 Reply
Gennady_F_Intel
Moderator
295 Views
Quoting - sangamesh
Hi,

With Intel MKL-10.0.5.025 and ifort-10.1.008, when static linking is used(Sequntial linking, link line is: $(MKLPATH)/libmkl_scalapack_lp64.a $(MKLPATH)/libmkl_solver_lp64_sequential.a -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_sequential.a $(MKLPATH)/libmkl_core.a $(MKLPATH)/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread)

the compilation fails with following error:

/opt/mpi/openmpi/1.3.3/intel/bin/mpif90 -I/opt/libs/netcdf/4.0.1/intel/include -o transiesta
automatic_cell.o atom_options.o arw.o atomlwf.o bands.o basis_enthalpy.o bessph.o bonds.o born_charge.o m_ts_aux_rout.o m_ts_kpoints.o m_ts_io.o m_ts_scattering.o m_ts_contour.o m_ts_electrode.o m_ts_in_siesta.o libfdf.a
libmpi_f90.a
dc_lapack.a liblapack.a libblas.a `FoX/FoX-config --libs --wcml` /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_scalapack_lp64.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_solver_lp64_sequential.a -Wl,--start-group /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_intel_lp64.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_sequential.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a /opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread /opt/libs/netcdf/4.0.1/intel/lib/libnetcdf.a
/opt/intel/fce/10.1.008/lib/libimf.so: warning: warning: feupdateenv is not implemented and will always fail
/opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a(zgesv.o): In function `mkl_lapack_zgesv':
__tmp_zgesv.f:(.text+0xbf): undefined reference to `mkl_lapack_zgetrf'
/opt/intel/mkl/10.0.5.025/lib/em64t/libmkl_core.a(zgetrs.o): In function `mkl_lapack_zgetrs':
__tmp_zgetrs.f:(.text+0x1fe): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x27f): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x30b): undefined reference to `mkl_blas_ztrsm'
__tmp_zgetrs.f:(.text+0x386): undefined reference to `mkl_blas_ztrsm'

But if the same link line is added with dynamic libraries, then it compiles successfully.

MKLPRL=-L$(MKLPATH) -lmkl_lapack -lmkl_core $(MKLPATH)/libmkl_scalapack_lp64.a $(MKLPATH)/libmkl_solver_lp64_sequential.a -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_sequential.a $(MKLPATH)/libmkl_core.a $(MKLPATH)/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread

Why so?

Please justify am I doing anything wrong? or its a problem with static library?

Thank you
sangamesh,
Can you remove "dc_lapack.a liblapack.a libblas.a" libraries from your linking line?
--Gennady
0 Kudos
Reply