Link Error while compiling legacy code
Show older comments
I have a c file for legacy code tool. I converted that to Matlab script and calling the function. There is this error:
mex('SPrintF_4_0_sf.c',IC:....\workspace\xxx_Resources\Simulink_Lib') Creating library C:\apps\Matlab\Temp\mex_6x2QlQ\templib.x and object C:\apps\Matlab\Temp\mex_6x2QlQ\templib.exp SPrintF_4_0_sf.obj : error LNK2019: unresolved external symbol LegacyCode_SPrintF_4_0 referenced in function mdlOutputs SPrintF_4_0_sf.mexw64 : fatal error LNK1120: 1 unresolved externals
C:\APPS\MATLAB\R2012B~1\BIN\MEX.PL: Error: Link of 'SPrintF_4_0_sf.mexw64' failed.
I am trying to call a function
Spec = legacy_code('initialize'); Spec.SFunctionName = 'SPrintF_4_0_sf'; Spec.OutputFcnSpec = 'void LegacyCode_SPrintF_4_0()'; Spec.HeaderFiles = {'stdio.h'}; Spec.Options.canBeCalledConditionally = true; Spec.Options.supportsMultipleExecInstances = true; legacy_code('generate_for_sim',Spec); legacy_code('slblock_generate',Spec);
function LegacyCode_SPrintF_4_0()
%****************************************************************************%
% #define ARRAYSIZE 5 clc; clear all; double absValue; double tempValue; double Number; %ARRAYSIZE = 5; %register float tempValue; uint tempint;
out = blanks(5); % _attribute_ ((aligned (8))); / / local data to collect character string % blanksignarray = ' '; % Scale Factor is 10 %
double MAXVALUE ; %Maximum value of the readout %
MAXVALUE = 99990;
double MINVALUE ; %Actual value of min value displayed.%
MINVALUE = -9990;
%Used in comparison with the raw
%number
% And to set the minimum value %
double RNDOFFVALUE; % Number used in rounding off to the least %
RNDOFFVALUE = 5;
% significant digit %
% do the following at init % % null terminator in last position assigned directly at end %
% Make a local copy of the raw number %
Number=10 ; % temp declaration tempValue = Number * 10;
%tempValue = 10;
%Peg at Minimum value for readout, as necessary % %Use raw number since it hasn't been converted to absoulte value % if ( tempValue MINVALUE ) tempValue = MINVALUE; end % Obtain the absoulte value % if (tempValue < 0.0) absValue = -tempValue; else absValue = tempValue; end % For a negative number, assign the negative sign % if ( tempValue <= -RNDOFFVALUE ) blanksignarray = '-----'; end %Adjust the temp value for rounding of last digit later and scale % tempValue = (absValue + RNDOFFVALUE); % Peg at Maximum value for readout, as necessary % if (tempValue > MAXVALUE) tempValue = MAXVALUE; end % Peel off the digits and assign to the out array % tempint = uint8(tempValue * 0.0001); % khts - k.hts -> k % % tempint = logical(tempint); out(1) = tempint +'0'; tempValue = tempValue - (tempint * 10000); % khts -> 0hts %
tempint = uint8(tempValue * 0.001); % 0hts -> h.ts -> h %
out(2) = tempint +'0';
tempValue = tempValue - (tempint * 1000); % 0hts -> 00ts %
tempint = uint8(tempValue * 0.01); % 00ts -> t.s -> t %
out(3) = tempint + '0';
tempValue = tempValue - (tempint * 100); % 00ts -> 000s %
tempint = uint8(tempValue * 0.1); % 000s -> s (floor) %
out(4) = tempint + '0';
% Replace leading zeros with blanks or sign as appropriate %
% Position
% 0123 0123
% 0xxx => bxxx
% -0xxx => -xxx
%
% Position
% 0123 0123
% 00xx => bbxx
% -00xx => b-xx
%
% Position
% 0123 0123
% 000x => bbbx
% -000x => bb-x
% msgbox(out(3)); if ( out(1) == '0' )
if ( out(2) ~= '0' )
out(1) = blanksignarray(1);
else
out(1) = ' ';
end
if out(3) ~= '0'
out(2) = blanksignarray(2); %blankorsign; %blankorsign;
else
out(2) = ' ';
end
out(1) = '';
if out(4) ~= '0'
out(3) = blanksignarray(2);
else
out(3) = ' ';
end
end
% Copy over 32 bits, array alements (digits) 0 to 3
ASCII_Out = uint (out);
% Copy over the last 8 bits %
% ASCII_Out(4) = 0;
%*********************************************************%
Answers (0)
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!