how to solve the error says : "The function sym is not supported for standalone ..." when I convert the Matlab code to C/C++ code??

4 ビュー (過去 30 日間)
abdullah hamdan aldassouki
abdullah hamdan aldassouki 2017 年 8 月 13 日
回答済み: upol 2018 年 12 月 27 日
I am trying to convert Matlab code to c/c++ code but I get error says "The function sym is not supported for standalone application" ..

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 8 月 13 日
The symbolic toolbox cannot be compiled or code generated at all.
You need to split your program into two parts. One part uses uncompiled MATLAB and user input and the symbolic toolbox to arrive at a particular formula. Then it uses matlabFunction to write the formula to a file as .m code that does not use symbolics at all.
Then the second part of your project would be code that accepted user interaction etc. and called upon the above mentioned nonsymbolic code. This part could be compiled or code generated.
Note that this requires a distinct compilation or code generation for each different formula created by the first part of the project.
  1 件のコメント
omkar waghmare
omkar waghmare 2018 年 6 月 26 日
Hello Walter, This answer was extremely helpful and helped me solve something on which I was stuck for about 2 days. Thanks again!

サインインしてコメントする。


upol
upol 2018 年 12 月 27 日
I am trying to convert this simple code into excutable using matlab coder.
function y = hello_world
%#codegen
y = 'Hello World!';
converting to source code C works but when i change the build type to Executable
It gives me this error: Build error: C compiler produced errors. See the Build Log for further details.
C:/PROGRA~3/MATLAB/SUPPOR~1/R2018b/3P778C~1.INS/MINGW_~1.INS/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib/../lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
gmake: *** [C:/dummy/hello_world.exe] Error 1
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
Error(s) encountered while building "hello_world":
### Failed to generate all binary outputs.

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by