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

OneAPI MKL static link fails using ifort

Multipath
Novice
1,506 Views

We are having problems using the FORTRAN compiler to perform a static link of MKL. Here is what works and fails:

WORKS:

1. Using ld to create a shared object version of our library and including:

/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.a
/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_sequential.a
/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_core.a

2. Using ifort to create a program and including the

-qmkl=sequential

flag.

However this ignores the specified .a versions and uses the .so versions.

FAILS:

Using ifort to create a program and using the recommendations of the Link Line Advisor

-Wl,--start-group
/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.a
/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_sequential.a
/Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_core.a
-Wl,--end-group

This produces pages of errors of the form:

/Intel/Linux/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort ld: fmslib.a(rsdaf.o): in function `rsdaf_.h': rsdaf.f:(.text+0x21c7): undefined reference to `dscal_' ld: rsdaf.f:(.text+0x2282): undefined reference to `daxpy_' ld: fmslib.a(rsdaf.o): in function `rsdaf_.A':
rsdaf.f:(.text+0x5ea8): undefined reference to `dscal_'
ld: rsdaf.f:(.text+0x5f5f): undefined reference to `daxpy_' ld: fmslib.a(rndaf.o): in function `rndaf_.h':
rndaf.f:(.text+0x2249): undefined reference to `dscal_' ld: rndaf.f:(.text+0x2304): undefined reference to `daxpy_'
ld: fmslib.a(rndaf.o): in function `rndaf_.A':
rndaf.f:(.text+0x602d): undefined reference to `dscal_'
ld: rndaf.f:(.text+0x60e4): undefined reference to `daxpy_' ld: fmslib.a(chdaf.o): in function `chdaf_.h': chdaf.f:(.text+0x21e8): undefined reference to `dscal_' ld: chdaf.f:(.text+0x22fc): undefined reference to `daxpy_'
ld: fmslib.a(chdaf.o): in function `chdaf_.A':
chdaf.f:(.text+0x5c81): undefined reference to `dscal_'
ld: chdaf.f:(.text+0x5d93): undefined reference to `daxpy_'

...

 

Any suggestions?

 

Thanks, Ron

 

 

 

 

0 Kudos
11 Replies
JNichols
New Contributor I
1,485 Views

Try the MKL forum.  There are experts there. 

0 Kudos
Multipath
Novice
1,367 Views

What is the link for posting to the MJKOL forum?

Thanks, Ro n

0 Kudos
Multipath
Novice
1,356 Views

Sorry for the typo -

 

It should read what is the link for posting to the MKL forum?

0 Kudos
mecej4
Honored Contributor III
1,409 Views

You may have built fmslib.a from objects produced by using a Fortran compiler different from Intel Fortran, as the trailing underscores in the missing externals indicate. 

0 Kudos
Multipath
Novice
1,366 Views

Everything was built with the following FORTRAN and C compilers

 

/Intel/Linux/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort
/Intel/Linux/oneapi/compiler/2022.0.2/linux/bin/intel64/icc

 

Ron

 

0 Kudos
JNichols
New Contributor I
1,363 Views

Ron:

The expert has found you, good hunting. 

0 Kudos
mecej4
Honored Contributor III
1,273 Views

Please show more details regarding the command line used for linking. In particular, show the order in which your library name and the MKL library names were specified in the linking command. If you used a makefile, please show the relevant portions of the makefile.

0 Kudos
Multipath
Novice
1,177 Views

The application MatrixWarrior is written in a combination of FORTRAN and C.

Intel compilers are used.

It depends on the Nvidia CUDA software and Intel's MKL.

The MKL library reference is repeated.

Here is the command line:

ifort -auto -threads -reentrancy threaded -fpic -ftz -nofor-main -ldl -o MatrixWarrior_dbg MatrixWarrior.o mw.a fmsnoshr.a fmslib.a fmsint.a fmslib.a fmsint.a yesgpu.a fmslib.a fmsint.a fmslib.a fmsint.a yesgpu.a -Wl,--start-group /Nvidia/Linux/cuda-11.4/lib64/libculibos.a /Nvidia/Linux/cuda-11.4/lib64/libcublas_static.a /Nvidia/Linux/cuda-11.4/lib64/libcublasLt_static.a /Nvidia/Linux/cuda-11.4/lib64/libculibos.a /Nvidia/Linux/cuda-11.4/lib64/libcudart_static.a -lrt -Wl,--end-group /Intel/Linux/oneapi/compiler/2022.0.2/linux/compiler/lib/intel64_lin/libimf.a /Intel/Linux/oneapi/compiler/2022.0.2/linux/compiler/lib/intel64_lin/libirc.a /Intel/Linux/oneapi/compiler/2022.0.2/linux/compiler/lib/intel64_lin/libifport.a /Intel/Linux/oneapi/compiler/2022.0.2/linux/compiler/lib/intel64_lin/libsvml.a /Intel/Linux/oneapi/compiler/2022.0.2/linux/compiler/lib/intel64_lin/libirng.a /lib/x86_64-linux-gnu/libc-2.31.so /usr/lib/x86_64-linux-gnu/libc_nonshared.a /lib/x86_64-linux-gnu/libstdc++.so.6 -L /lib/x86_64-linux-gnu -L /usr/lib/gcc/x86_64-linux-gnu/9 -Wl,--start-group /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.a /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_sequential.a /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_core.a -Wl,--end-group -Wl,--start-group /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.a /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_sequential.a /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -ldl -lm

 

Thanks, Ron

0 Kudos
mecej4
Honored Contributor III
1,104 Views

Thanks for the detailed information as to the link line. Why is "fmslib.a fmsint.a" repeated four times, and "yesgpu.a" two times?

Other than that, I cannot see anything unusual. Although the repetitions many not be needed, they should have cause the linking to fail.

I second the suggestion that you post this problem report in the MKL Forum.

0 Kudos
Multipath
Novice
1,083 Views

Thanks for looking at this.

 

What is the link to the MKL Forum?

 

The libraries are repeated because there may be circular references that need to be resolved.  Probably too many times.

 

Note that if I simply add

 

-qmkl=sequential

 

to the link line it works

 

ls -al MatrixWarrior_dbg -rwxrwxr-x 1 ron ron 134192944 Mar 14 07:19 MatrixWarrior_dbg


ldd MatrixWarrior_dbg
linux-vdso.so.1 (0x00007fffeedfa000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8326566000)
libmkl_intel_lp64.so.2 => /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.so.2 (0x00007f83256c6000) libmkl_sequential.so.2 => /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_sequential.so.2 (0x00007f8323cac000)
libmkl_core.so.2 => /Intel/Linux/oneapi/mkl/2022.0.2/lib/intel64/libmkl_core.so.2 (0x00007f831f8f5000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f831f8eb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f831f6f9000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f831f517000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f831f4f4000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f831f3a5000) /lib64/ld-linux-x86-64.so.2 (0x00007f8326588000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f831f388000)

 

but it uses the shared object version of MKL.

0 Kudos
Multipath
Novice
1,081 Views

I noticed that your last response did include a hyperlink to the MKL Form so I posted the question there.

 

Thanks for your help.

 

Roin

0 Kudos
Reply