- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I found that mkl_tbb_thread.lib is linked to msvcrt.lib which is /MD correspondent CRT as described in C runtime (CRT) and C++ standard library (STL) .lib files
Maybe this library should be linked to libcmt.lib if it is for /MT CRT.
In other view, for as file naming, in mkl/2025.0/lib folder, there are tbb_thread libs as follow.
mkl_tbb_thread.lib
mkl_tbb_thread_dll.lib
mkl_tbb_threadd.lib
mkl_tbb_threadd_dll.lib
Filename looks like that each libs should be linked to /MT /MD /MTd /MDd each.
<environment>
oneapi 2025.0
windows 10
<reproducer>
Im trying to building in release config with /MT flag.
Im using onemkl with onetbb so, i set CMakeLists.txt as
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
set(MKL_THREADING tbb_thread)
and
F1 > CMake: Select Variant > Release in vscode
During linking, following error raised
mkl_tbb_thread.lib(bless_node_tbb.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.cpp.obj
<dumpbin>
I dumped the mkl_tbb_thread.lib file and found
Linker Directives
-----------------
/DEFAULTLIB:tbb12.lib
/DEFAULTLIB:msvcprt.lib
/FAILIFMISMATCH:RuntimeLibrary=MD_DynamicRelease
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We investigated the issue and it's not a bug. The naming convention of static .lib and dynamic _dll.lib libraries is more of a clue for the used when linking to MKL, that is mkl_tbb_thread.lib should be linked statically while mkl_tbb_thread_dll.lib should be linked dynamically. However, a static library can be linked to C runtime dynamically as the static library does not dictate how the C runtime is linked.
For further details on how to link to MKL please refer to Link Line Advisor for Intel® oneAPI Math Kernel Library
Regards,
Aleksandra
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you added all the 4 libs below in your static linking?
mkl_intel_lp64.lib mkl_tbb_thread.lib mkl_core.lib tbb12.lib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After read reply, I tried link 4 libs manually, but same link error raised.
I tried as below.
1. CMakeLists.txt
cmake_minimum_required(VERSION 3.28.0)
project(link_bug_test VERSION 0.0.0 LANGUAGES C CXX)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(${PROJECT_NAME}_FOUND TRUE PARENT_SCOPE)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
find_package(TBB REQUIRED COMPONENTS tbb tbbmalloc)
set(MKL_LINK static)
set(MKL_THREADING tbb_thread)
set(MKL_INTERFACE lp64)
find_package(MKL CONFIG REQUIRED PATHS $ENV{MKLROOT})
add_executable(link_bug_test
main.cpp
)
target_link_libraries(link_bug_test
PRIVATE TBB::tbb TBB::tbbmalloc
PRIVATE mkl_intel_lp64 mkl_tbb_thread mkl_core tbb12
# PRIVATE MKL::MKL
)
2. main.cpp
#include <mkl.h>
#include <oneapi/tbb.h>
int main(){
size_t N{65536};
float dt{1e-3};
MKL_Complex8* arr=(MKL_Complex8*)mkl_malloc(N*8,64);
for(size_t i=0;i<N;++i){
arr[i].real=sin(0.01*dt);
arr[i].imag=0;
}
DFTI_DESCRIPTOR_HANDLE fft_hand;
DftiCreateDescriptor(&fft_hand,DFTI_SINGLE,DFTI_COMPLEX,1,N);
DftiCommitDescriptor(fft_hand);
DftiComputeForward(fft_hand,arr);
oneapi::tbb::parallel_for(oneapi::tbb::blocked_range<size_t>(0,100000),[&](const oneapi::tbb::blocked_range<size_t>& r){
for(size_t i=r.begin();i!=r.end();i++){
arr[i].imag=0;
}
});
mkl_free(arr);
return ;
}
3. Configure
Used vscode command
F1 > CMake: Configure
Following was executed.
cmake.exe -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=icx -DCMAKE_CXX_COMPILER:FILEPATH=icx --no-warn-unused-cli -SC:/link_bug_test -Bc:/link_bug_test/build -G Ninja
4. Build
Used vscode command
F1 > CMake: Build
Following was executed
[build] Starting build
[proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build c:/link_bug_test/build --config Release --target all --
5. Result error
[build] [2/2 100% :: 2.647] Linking CXX executable link_bug_test.exe
[build] FAILED: link_bug_test.exe
[build] C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\link_bug_test.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\icx.exe /nologo CMakeFiles\link_bug_test.dir\main.cpp.obj /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /Qoption,link,/subsystem:console "C:\Program Files (x86)\Intel\oneAPI\tbb\latest\lib\tbb12.lib" "C:\Program Files (x86)\Intel\oneAPI\tbb\latest\lib\tbbmalloc.lib" mkl_intel_lp64.lib mkl_tbb_thread.lib mkl_core.lib tbb12.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /link /out:link_bug_test.exe /implib:link_bug_test.lib /pdb:link_bug_test.pdb /version:0.0 && cd ."
[build] LINK: command "C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\icx.exe /nologo CMakeFiles\link_bug_test.dir\main.cpp.obj /Qoption,link,/machine:x64 /Qoption,link,/INCREMENTAL:NO /Qoption,link,/subsystem:console C:\Program Files (x86)\Intel\oneAPI\tbb\latest\lib\tbb12.lib C:\Program Files (x86)\Intel\oneAPI\tbb\latest\lib\tbbmalloc.lib mkl_intel_lp64.lib mkl_tbb_thread.lib mkl_core.lib tbb12.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /link /out:link_bug_test.exe /implib:link_bug_test.lib /pdb:link_bug_test.pdb /version:0.0 /MANIFEST:EMBED,ID=1" failed (exit code 1319) with the following output:
[build] mkl_tbb_thread.lib(bless_node_tbb.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.cpp.obj
[build] link_bug_test.exe : fatal error LNK1319: 1 mismatches detected
[build] icx: error: linker command failed with exit code 1319 (use -v to see invocation)
[build] ninja: build stopped: subcommand failed.
I tried linking at reporting this bug as follow.
cmake_minimum_required(VERSION 3.28.0)
project(link_bug_test VERSION 0.0.0 LANGUAGES C CXX)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(${PROJECT_NAME}_FOUND TRUE PARENT_SCOPE)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
find_package(TBB REQUIRED COMPONENTS tbb tbbmalloc)
set(MKL_LINK static)
set(MKL_THREADING tbb_thread)
set(MKL_INTERFACE lp64)
find_package(MKL CONFIG REQUIRED PATHS $ENV{MKLROOT})
add_executable(link_bug_test
main.cpp
)
target_link_libraries(link_bug_test
PRIVATE TBB::tbb TBB::tbbmalloc
PRIVATE MKL::MKL
)
which is normal when linking MKL with CMake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I wanted to let you know that I've reproduced the issue you mentioned, and we're working on fixing it. I'll keep you posted with any updates.
Thanks,
Aleksandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We investigated the issue and it's not a bug. The naming convention of static .lib and dynamic _dll.lib libraries is more of a clue for the used when linking to MKL, that is mkl_tbb_thread.lib should be linked statically while mkl_tbb_thread_dll.lib should be linked dynamically. However, a static library can be linked to C runtime dynamically as the static library does not dictate how the C runtime is linked.
For further details on how to link to MKL please refer to Link Line Advisor for Intel® oneAPI Math Kernel Library
Regards,
Aleksandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I appreciate your feedback.
I realized the my misunderstanding from your reply.
To summarize, linking static libraries to dynamic CRT(/MT, /MTd for MSVC) is also normal.
Also, MKL and TBB are linked to dynamic CRT for both static(<lib_name>.lib) and dynamic(<lib_name>_dll.lib) libraries.
Thank you again!

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