Skip to content

meson cannot find mkl_intel_thread #402

@awvwgk

Description

@awvwgk

Building with Intel oneAPI 2021.1 Classic Compilers and MKL currently fails with

meson/meson.build:77:4: ERROR: Fortran library 'mkl_intel_thread' not found

The meson log shows the following error:

Running compile:
Working directory:  /home/awvwgk/projects/src/git/xtb/_build_oneapi/meson-private/tmpq76llaig
Command line:  ifort /home/awvwgk/projects/src/git/xtb/_build_oneapi/meson-private/tmpq76llaig/testfile.f90 -o /home/awvwgk/projects/src/git/xtb/_build_oneapi/meson-private/tmpq76llaig/outpu
t.exe -D_FILE_OFFSET_BITS=64 -O0 -Wl,--start-group -lmkl_intel_thread -Wl,--end-group -Wl,--allow-shlib-undefined -diag-error 10006 -diag-error 10148 -diag-error 10155 -diag-error 10156 -dia
g-error 10157 -diag-error 10158 -diag-error 1292 

Code:
 stop; end program
Compiler stdout:
 
Compiler stderr:
 ld: /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/libifcoremt.a(for_vm.o): in function `for_allocate':
for_vm.c:(.text+0x426): undefined reference to `__kmpc_global_thread_num'
ld: for_vm.c:(.text+0x787): undefined reference to `__kmpc_global_thread_num'
ld: /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/libifcoremt.a(for_vm.o): in function `for_alloc_allocatable':
for_vm.c:(.text+0xb03): undefined reference to `__kmpc_global_thread_num'
ld: for_vm.c:(.text+0xe5e): undefined reference to `__kmpc_global_thread_num'
ld: /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/libifcoremt.a(for_vm.o): in function `for_deallocate':
for_vm.c:(.text+0x118d): undefined reference to `__kmpc_global_thread_num'
ld: /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/libifcoremt.a(for_vm.o):for_vm.c:(.text+0x128d): more undefined references to `__kmpc_global_thread_num' follow

A workaround is to add -Dfortran_link_args=-qopenmp in the setup step, since the globally added link argument will bleed into the command options used to find the libraries in meson. Not the best solution though.

Opening this issue to document the current situation and possible workarounds. Thanks to @cbannwarth for bringing this issue to my attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildBuild system related issues (OS, compilers, meson)documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions