Error 2061, 2059 while using CMath library in legacy code tool

19 ビュー (過去 30 日間)
Heidar Alshabany
Heidar Alshabany 2020 年 1 月 23 日
コメント済み: Walter Roberson 2020 年 1 月 23 日
I've been trying to use the legacy_code tool to interface between some exisiting C++ code with Simulink. I've encountered errors when using standard C++ libraries in the code. The error was resolved when I used a C library (math.h) instead of cmath. The short demo code allowed for the conversion but is there anyway to implement the usage of C++ libraries within legacy_code tool.
The error message that popped up
### Start Compiling SL_demo_sine
mex('-IC:\Users\AGanesh\Documents\Aditya_temp\C_code', '-c', '-outdir', 'C:\Users\AGanesh\AppData\Local\Temp\tpbef4bbb6_bdbf_4da0_9691_b444ad7ac279', 'C:\Users\AGanesh\Documents\Aditya_temp\C_code\GetResult.c')
Building with 'Microsoft Windows SDK 7.1 (C)'.
Error using mex
GetResult.c
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(19) : error C2061: syntax error : identifier 'acosf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(19) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(19) : error C2061: syntax error : identifier 'asinf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(19) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2061: syntax error : identifier 'atanf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2061: syntax error : identifier 'atan2f'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2061: syntax error : identifier 'ceilf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(20) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2061: syntax error : identifier 'cosf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2061: syntax error : identifier 'coshf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2061: syntax error : identifier 'expf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(21) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2061: syntax error : identifier 'fabsf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2061: syntax error : identifier 'floorf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2061: syntax error : identifier 'fmodf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(22) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2061: syntax error : identifier 'frexpf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2061: syntax error : identifier 'ldexpf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2061: syntax error : identifier 'logf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(23) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2061: syntax error : identifier 'log10f'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2061: syntax error : identifier 'modff'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2061: syntax error : identifier 'powf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(24) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2061: syntax error : identifier 'sinf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2061: syntax error : identifier 'sinhf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2061: syntax error : identifier 'sqrtf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(25) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(26) : error C2061: syntax error : identifier 'tanf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(26) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(26) : error C2061: syntax error : identifier 'tanhf'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(26) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(28) : error C2061: syntax error : identifier 'acosl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(28) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(28) : error C2061: syntax error : identifier 'asinl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(28) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2061: syntax error : identifier 'atanl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2061: syntax error : identifier 'atan2l'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2061: syntax error : identifier 'ceill'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(29) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2061: syntax error : identifier 'cosl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2061: syntax error : identifier 'coshl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2061: syntax error : identifier 'expl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(30) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2061: syntax error : identifier 'fabsl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2061: syntax error : identifier 'floorl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2061: syntax error : identifier 'fmodl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(31) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2061: syntax error : identifier 'frexpl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2061: syntax error : identifier 'ldexpl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2061: syntax error : identifier 'logl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(32) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2061: syntax error : identifier 'log10l'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2061: syntax error : identifier 'modfl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2061: syntax error : identifier 'powl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(33) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2061: syntax error : identifier 'sinl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2061: syntax error : identifier 'sinhl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2061: syntax error : identifier 'sqrtl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(34) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(35) : error C2061: syntax error : identifier 'tanl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(35) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(35) : error C2061: syntax error : identifier 'tanhl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(35) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(37) : error C2061: syntax error : identifier 'abs'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(37) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(39) : error C2061: syntax error : identifier 'acos'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(39) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(39) : error C2061: syntax error : identifier 'asin'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(39) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2061: syntax error : identifier 'atan'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2061: syntax error : identifier 'atan2'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2061: syntax error : identifier 'ceil'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(40) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(41) : error C2061: syntax error : identifier 'cos'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\cmath(41) : fatal error C1003: error count exceeds 100; stopping
compilation
Error in legacycode.LCT/compile
Error in legacycode.LCT/generatesimfiles
Error in legacycode.LCT.legacyCodeImpl
Error in legacy_code (line 101)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Any help in this regard will be appreciated.
Thanks
Aditya
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 23 日
Why are you using a .c file extension for C++ code? The .c file extension is reserved for C code.
On some systems, .C (capital) is permitted for C++ code, but it is safer to use .cpp file extension.

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

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by