Why does my code generated from MATLAB Coder fail to compile because of missing function definitions for "omp_init_nest_lock" and "omp_destroy_nest_lock"?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 31 Mär. 2017
Beantwortet: cui,xingxing
am 15 Feb. 2024
Why does my code generated from MATLAB Coder fail to compile because of missing function definitions for "omp_init_nest_lock" and "omp_destroy_nest_lock"?
I am trying to compile the code on a Linux operating system and it fails because the compiler cannot find definitions for the mentioned functions. I do not know why these functions are appear in my code. I also noticed that the same code compiles on a different computer with a Windows operating system using Microsoft Visual Studio.
Akzeptierte Antwort
MathWorks Support Team
am 23 Aug. 2021
Bearbeitet: MathWorks Support Team
am 26 Aug. 2021
This issue is typically encountered if the Linux computer on which the code is being compiled has an outdated compiler. The functions "omp_init_nest_lock" and "omp_destroy_nest_lock" are implementations of "OpenMP" specifications and they should be provided by the compiler. On a Linux computer, installing the recommended version of the GCC compiler should resolve this issue.
Information about supported compilers for the current MATLAB release can be found at the following link:
Information about supported compilers for the previous MATLAB releases can be found at the following link:
Note: this also addresses a similar issue on Ubuntu.
1 Kommentar
Ryan Livingston
am 17 Apr. 2017
addresses a similar issue on Ubuntu.
Weitere Antworten (1)
cui,xingxing
am 15 Feb. 2024
If you use the CMake tool to compile, then it should link to the OpenMP library. Add the following example to CMakeLists.txt.
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
0 Kommentare
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!