- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
My context:
- `uname -a`: "Linux XXXX-XXXXX 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux".
- 'c++ --version': "c++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0"
- MKL: 2025.0
- 'cmake --version': "cmake version 3.28.3"
I am trying to link some programs. When I use .so's, it works. When I switch to .a's, I get undefined symbols.
The link/libraries command line is, in part, "/usr/bin/c++ test.cpp -o test ... -Wl,-Bstatic -lmkl_intel_lp64 -lmkl_core -lmkl_gnu_thread -Wl,-Bdynamic -lpthread ...".
When I run the above, I get the follow error: "/usr/bin/ld: /opt/intel/oneapi/mkl/latest/lib/intel64/libmkl_gnu_thread.a(s__axpy_drv.o): in function `level1_internal_thread':
_axpy.c:(.text+0xbd): undefined reference to `mkl_blas_xsaxpy'
/usr/bin/ld: /opt/intel/oneapi/mkl/latest/lib/intel64/libmkl_gnu_thread.a(s__axpy_drv.o): in function `mkl_blas_saxpy':
_axpy.c:(.text+0x20c): undefined reference to `mkl_blas_xsaxpy'
collect2: error: ld returned 1 exit status".
If I run it with the "-Wl,-Bstatic/-Wl,-Bdynamic" removed, it links and runs without issue.
The "mkl_intel_lp64, mkl_core, mkl_gnu_thread" libraries are the only MKL libraries being used.
When I query the mkl_gnu_thread library, I get the following:
'nm /opt/intel/oneapi/mkl/2025.0/lib/libmkl_gnu_thread.a| grep mkl_blas_xsaxpy':
"U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
U mkl_blas_saxpy
0000000000000000 T mkl_blas_saxpy_direct
0000000000000160 T mkl_blas_saxpy
U mkl_blas_saxpy
0000000000000170 T mkl_blas_saxpy_batch
0000000000000430 T mkl_blas_saxpy_batch_strided"
So the symbol seems to be defined (bolding added for clarification).
I have shuffled the order of the "-lmkl_..."s, and get different amount of undefined symbols, with the minimum being listed near the top of the page, so that is not a solution.
The symbol "mkl_blas_xsaxpy" is not used anywhere in my source code.
What do I need to do to get this to link correctly?
Thank you in advance,
Eric L.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eric L,
For oneMKL 2025.0 system requirement, please check here, to make sure your system meets its requirement. Also, Intel® oneAPI Math Kernel Library (oneMKL) Link Line Advisor can help you how to compile or link oneMKL libs.
If the issue still exist, please share us a simple reproducer, as well as introduce how to reproduce it.
Regards,
Ruqiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a near-by example (I can't provide the actual source code as it is too large and proprietary), but this produces a similar error:
$ cat test2.cpp
#include <iostream>
#include <mkl_blas.h>
int main(int argc, char **argv)
{
for(int i=0; i<argc; ++i)
{
std::cout << "argv[" << i << "]=" << argv[i] << std::endl;
}
MKL_INT n=0;
float alpha;
float x;
MKL_INT incx=1.0;
float beta=1.0;
float y=0.0f;
MKL_INT incy;
SAXPBY(&n, &alpha, &x, &incx, &beta, &y, &incy);
return 0;
}
[Works without issue.]
$ g++ test2.cpp -o test2 -I/opt/intel/oneapi/mkl/2025.0/include -L/opt/intel/oneapi/mkl/2024.2/lib -lmkl_intel_lp64 -lmkl_core -lmkl_gnu_thread -lgomp
$
[The next fails to compile.]
$ g++ test2.cpp -o test2 -I/opt/intel/oneapi/mkl/2025.0/include -L/opt/intel/oneapi/mkl/2024.2/lib -Wl,-Bstatic -lmkl_intel_lp64 -lmkl_core -lmkl_gnu_thread -Wl,-Bdynamic -lgomp
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(s__axpby_drv.o): in function `level1_internal_thread':
_axpby.c:(.text+0xc9): undefined reference to `mkl_blas_xsaxpby'
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(s__axpby_drv.o): in function `mkl_blas_saxpby':
_axpby.c:(.text+0x1d5): undefined reference to `mkl_blas_xsaxpby'
/usr/bin/ld: _axpby.c:(.text+0x292): undefined reference to `mkl_serv_cpu_detect'
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(mkl_threading_mp_gnu.o): in function `MKL_Read_ThreadENV_Count_Cores':
mkl_threading.c:(.text+0xd7b): undefined reference to `mkl_serv_malloc'
/usr/bin/ld: mkl_threading.c:(.text+0xd93): undefined reference to `mkl_serv_malloc'
/usr/bin/ld: mkl_threading.c:(.text+0xdb3): undefined reference to `mkl_serv_malloc'
/usr/bin/ld: mkl_threading.c:(.text+0x13f8): undefined reference to `mkl_serv_free'
/usr/bin/ld: mkl_threading.c:(.text+0x1400): undefined reference to `mkl_serv_free'
/usr/bin/ld: mkl_threading.c:(.text+0x1408): undefined reference to `mkl_serv_free'
/usr/bin/ld: mkl_threading.c:(.text+0x1746): undefined reference to `mkl_serv_free'
/usr/bin/ld: mkl_threading.c:(.text+0x175e): undefined reference to `mkl_serv_free'
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(mkl_threading_mp_gnu.o):mkl_threading.c:(.text+0x1768): more undefined references to `mkl_serv_free' follow
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(mkl_print_verbose_mp_gnu.o): in function `mkl_serv_print_verbose_header':
mkl_print_verbose.c:(.text+0x31): undefined reference to `mkl_serv_get_version'
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(mkl_print_verbose_mp_gnu.o): in function `mkl_serv_print_verbose_info':
mkl_print_verbose.c:(.text+0x308): undefined reference to `mkl_serv_cbwr_get'
/usr/bin/ld: mkl_print_verbose.c:(.text+0x36f): undefined reference to `mkl_serv_cbwr_get'
/usr/bin/ld: mkl_print_verbose.c:(.text+0x3b5): undefined reference to `mkl_serv_get_fast_mm_status'
/usr/bin/ld: /opt/intel/oneapi/mkl/2024.2/lib/libmkl_gnu_thread.a(mkl_thr_cleanup_mp_gnu.o): in function `mkl_serv_thr_register_cleanup':
mkl_thr_cleanup.c:(.text+0x33): undefined reference to `mkl_serv_exit'
collect2: error: ld returned 1 exit status
The only difference is the "-Wl,-Bstatic" and "-Wl,-Bdynamic" delimiters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We recommend you use the compile options below from Intel® oneAPI Math Kernel Library (oneMKL) Link Line Advisor
g++ test2.cpp -o test2 -m64 -I"${MKLROOT}/include" -Wl,--start-group ${MKLROOT}/lib/libmkl_intel_lp64.a ${MKLROOT}/lib/libmkl_gnu_thread.a ${MKLROOT}/lib/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page