Matlab Coder fails to generate executable using coder.ceval
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to generate a minimal example to generate a C executable with Matlab Coder including native C code using coder.ceval I can create the full c-code from my Matlab code, however generating the executable fails. I am trying to compile the absval example from the Matlab documentation: http://nl.mathworks.com/help/simulink/slref/coder.ceval.html
My program structure looks the following:
absval.m:
function y = absval(u) %#codegen
y = abs(u);
From this I generated c-code using
codegen -config:lib absval -args {0.0}
The c-code is called by callabsval.m
function y = callabsval %#codegen
y = -2.75;
coder.ceval('absval_initialize');
y = coder.ceval('absval',y);
coder.ceval('absval_terminate');
As a last step I want to use Matlab Coder to generate a standalone c executable from callabsval.m, however the build fails with the output:
SummaryAll Messages (2)VariablesTarget Build Log
Build Parameters
Build directory /path/absval/codegen/exe/callabsval
Build Log
1 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "callabsval_initialize.o" "callabsval_initialize.c"
2 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "callabsval_terminate.o" "callabsval_terminate.c"
3 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "callabsval.o" "callabsval.c"
4 callabsval.c:30:3: warning: implicit declaration of function 'absval_initialize' is invalid in C99 [-Wimplicit-function-declaration]
5 absval_initialize();
6 ^
7 callabsval.c:33:7: warning: implicit declaration of function 'absval' is invalid in C99 [-Wimplicit-function-declaration]
8 y = absval(-2.75);
9 ^
10 callabsval.c:37:3: warning: implicit declaration of function 'absval_terminate' is invalid in C99 [-Wimplicit-function-declaration]
11 absval_terminate();
12 ^
13 3 warnings generated.
14 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "rt_nonfinite.o" "rt_nonfinite.c"
15 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "rtGetNaN.o" "rtGetNaN.c"
16 xcrun clang -c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -fno-common -fexceptions -O0 -g -DMODEL=callabsval -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/path/absval -I/path/absval/codegen/exe/callabsval -I/Applications/MATLAB_R2016a.app/extern/include -I/Applications/MATLAB_R2016a.app/simulink/include -I/Applications/MATLAB_R2016a.app/rtw/c/src -I/Applications/MATLAB_R2016a.app/rtw/c/src/ext_mode/common -I/Applications/MATLAB_R2016a.app/rtw/c/ert -o "rtGetInf.o" "rtGetInf.c"
17 ### Creating standalone executable /path/absval/callabsval ...
18 xcrun clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -Wl,-rpath,/Applications/MATLAB_R2016a.app/bin/maci64 -Wl,-rpath,@executable_path -Wl,-rpath,@executable_path//path/absval -L"/Applications/MATLAB_R2016a.app/bin/maci64" -g -o /path/absval/callabsval callabsval_initialize.o callabsval_terminate.o callabsval.o rt_nonfinite.o rtGetNaN.o rtGetInf.o -lm
19 Undefined symbols for architecture x86_64:
20 "_absval", referenced from:
21 _callabsval in callabsval.o
22 "_absval_initialize", referenced from:
23 _callabsval in callabsval.o
24 "_absval_terminate", referenced from:
25 _callabsval in callabsval.o
26 "_main", referenced from:
27 implicit entry/start for main executable
28 ld: symbol(s) not found for architecture x86_64
29 clang: error: linker command failed with exit code 1 (use -v to see invocation)
30 gmake: *** [/path/absval/callabsval] Error 1
31
32 Error(s) encountered while building "callabsval":
33 ### Failed to generate all binary outputs.
I'm trying this on MacOS 10.11.5 using Matlab 2016a. Any help is greatly appreciated!
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Build Configuration 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!