Reputation: 75
I'm developing a mobile application on Android Studio based on a code generated by MATLAB Coder.
I've just added the .c files on CmakeFiles.txt to check if the gradle would compile. Instead, it is throwing the following error:
ld: error: undefined symbol: omp_init_nest_lock
The function is called from the following code:
/*
* Student License - for use by students to meet course requirements and
* perform academic research at degree granting institutions only. Not
* for government, commercial, or other organizational use.
*
* Android3_initialize.c
*
* Code generation for function 'Android3_initialize'
*
*/
/* Include files */
#include "Android3_initialize.h"
#include "Android3_data.h"
#include "rt_nonfinite.h"
#include "omp.h"
/* Function Definitions */
void Android3_initialize(void)
{
omp_init_nest_lock(&Android3_nestLockGlobal);
isInitialized_Android3 = true;
}
/* End of code generation (Android3_initialize.c) */
Error log:
cmd.exe /C "cd . && C:\Users\Fortu\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=aarch64-none-linux-android21 --sysroot=C:/Users/Fortu/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libocc.so -o C:\Users\Fortu\AndroidStudioProjects\OCC\app\build\intermediates\cxx\Debug\13431l6d\obj\arm64-v8a\libocc.so CMakeFiles/occ.dir/main.c.o CMakeFiles/occ.dir/Android3.c.o CMakeFiles/occ.dir/Android3_data.c.o CMakeFiles/occ.dir/Android3_emxAPI.c.o CMakeFiles/occ.dir/Android3_emxutil.c.o CMakeFiles/occ.dir/Android3_initialize.c.o CMakeFiles/occ.dir/Android3_terminate.c.o CMakeFiles/occ.dir/cellstr_sort.c.o CMakeFiles/occ.dir/cellstr_strtrim.c.o CMakeFiles/occ.dir/cellstr_unique.c.o CMakeFiles/occ.dir/conv2dDirectOptimizedColMajor.c.o CMakeFiles/occ.dir/elementwiseOperationInPlace.c.o CMakeFiles/occ.dir/find.c.o CMakeFiles/occ.dir/heapsort.c.o CMakeFiles/occ.dir/imcrop.c.o CMakeFiles/occ.dir/imresize.c.o CMakeFiles/occ.dir/insertionsort.c.o CMakeFiles/occ.dir/introsort.c.o CMakeFiles/occ.dir/nullAssignment.c.o CMakeFiles/occ.dir/poolingOperation.c.o CMakeFiles/occ.dir/predict.c.o CMakeFiles/occ.dir/Resize2DLayer.c.o CMakeFiles/occ.dir/rt_nonfinite.c.o CMakeFiles/occ.dir/rtGetInf.c.o CMakeFiles/occ.dir/rtGetNaN.c.o CMakeFiles/occ.dir/sort.c.o CMakeFiles/occ.dir/sortIdx.c.o CMakeFiles/occ.dir/YOLOv4ObjectDetector.c.o C:/Users/Fortu/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/21/liblog.so -latomic -lm && cd ."
ld: error: undefined symbol: omp_init_nest_lock
>>> referenced by Android3_initialize.c:21 (C:/Users/Fortu/AndroidStudioProjects/OCC/app/src/main/cpp/Android3_initialize.c:21)
>>> CMakeFiles/occ.dir/Android3_initialize.c.o:(Android3_initialize)
From this post on the MathWorks forum, this seems to be a compiler issue: https://www.mathworks.com/matlabcentral/answers/333784-why-does-my-code-generated-from-matlab-coder-fail-to-compile-because-of-missing-function-definitions
However, from my knowledge, Android NDK-25 (which is the one I'm using) does support OpenMP and its specifications, so I don't understand why the function is not recognized.
Any ideas on how to fix this?
Upvotes: 1
Views: 191
Reputation: 1
Check if the following has been specified.
For this check the makefile emitted with the generated code.
Upvotes: 0