My external C function called by stateflow is not recognized during code generation.

1 次查看(过去 30 天)
I added the file name in the custom code as well as simulation target. But I get the following error message while generating code: Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.
### Compiling BusAtruProtection.c
cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_MT -D_DLL -MD -D_CRT_SECURE_NO_WARNINGS -DSLMSG_ALLOW_SYSTEM_ALLOC /Od /Oy- /DNDEBUG -DMODEL=BusAtruProtection -DNUMST=2 -DNCSTATES=0 -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=0 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMDL_REF_SIM_TGT=1 -DENABLE_SLEXEC_SSBRIDGE=11 BusAtruProtection.c
BusAtruProtection.c
BusAtruProtection.c(906) : warning C4013: 'InitAtruVoltageBuffer' undefined; assuming extern returning int
BusAtruProtection.c(911) : warning C4013: 'UpdateAtruDiffVoltage' undefined; assuming extern returning int
BusAtruProtection.c(935) : warning C4127: conditional expression is constant
### Compiling BusAtruProtection_capi.c
cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_MT -D_DLL -MD -D_CRT_SECURE_NO_WARNINGS -DSLMSG_ALLOW_SYSTEM_ALLOC /Od /Oy- /DNDEBUG -DMODEL=BusAtruProtection -DNUMST=2 -DNCSTATES=0 -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=0 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMDL_REF_SIM_TGT=1 -DENABLE_SLEXEC_SSBRIDGE=11 BusAtruProtection_capi.c
BusAtruProtection_capi.c
Z:\sys\perl\win32\bin\perl Z:\rtw\c\tools\mkvc_lnk.pl BusAtruProtection.lnk BusAtruProtection.obj BusAtruProtection_capi.obj ConditionFixedTD.obj ConditionFixedTDwithInhibit.obj OneshotTD_Falling_Edge.obj OneshotTD_Rising_Edge.obj OverProtectionWithInhibitAndCondition.obj UnderProtectionWithInhibitAndCondition.obj
link -lib /OUT:BusAtruProtectionlib.lib @BusAtruProtection.lnk
Microsoft (R) Library Manager Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
BusAtruProtection.obj
BusAtruProtection_capi.obj
ConditionFixedTD.obj
ConditionFixedTDwithInhibit.obj
OneshotTD_Falling_Edge.obj
OneshotTD_Rising_Edge.obj
OverProtectionWithInhibitAndCondition.obj
UnderProtectionWithInhibitAndCondition.obj
Created static library BusAtruProtectionlib.lib
Z:\bin\mex -win64 OPTIMFLAGS="/Od /Oy- /DNDEBUG" -DMDL_REF_SIM_TGT=1 -DENABLE_SLEXEC_SSBRIDGE=11 -f "C:\Users\maddalvx\AppData\Roaming\MathWorks\MATLAB\R2016a\mex_C_win64.xml" BusAtruProtection_msf.c BusAtruProtectionlib.lib @BusAtruProtection_ref.rsp ..\..\..\slprj\sim\_sharedutils\rtwshared.lib Z:\extern\lib\win64\microsoft\libfixedpoint.lib Z:\lib\win64\libmwipp.lib Z:\extern\lib\win64\microsoft\libmwslexec_simbridge.lib Z:\extern\lib\win64\microsoft\libmwmathutil.lib Z:\extern\lib\win64\microsoft\libmwsimulink.lib Z:\extern\lib\win64\microsoft\libmwsl_fileio.lib Z:\extern\lib\win64\microsoft\libmwsl_iofile.lib Z:\extern\lib\win64\microsoft\libmwsigstream.lib Z:\extern\lib\win64\microsoft\libmwsl_log_load_blocks.lib Z:\extern\lib\win64\microsoft\libmwsl_AsyncioQueue.lib Z:\extern\lib\win64\microsoft\libmwcoder_ToAsyncQueueTgtAppSvc.lib Z:\extern\lib\win64\microsoft\sf_runtime.lib -outdir ..\..\..
Building with 'Microsoft Windows SDK 7.1 (C)'.
Creating library C:\Matlab\AGE21011E_2016a\Model\BusAtruProtection_msf.lib and object C:\Matlab\AGE21011E_2016a\Model\BusAtruProtection_msf.exp
BusAtruProtectionlib.lib(BusAtruProtection.obj) : error LNK2019: unresolved external symbol UpdateAtruDiffVoltage referenced in function joeylifcnq
BusAtruProtectionlib.lib(BusAtruProtection.obj) : error LNK2019: unresolved external symbol InitAtruVoltageBuffer referenced in function joeylifcnq
C:\Matlab\AGE21011E_2016a\Model\BusAtruProtection_msf.mexw64 : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: 'Z:\bin\mex.BAT' : return code '0xffffffff'
Stop.
  1 个评论
Abhi Sundararaman
Abhi Sundararaman 2017-10-9
Are there any header files your .c file depends on? The errors you're getting suggest that something was not properly defined.
BusAtruProtectionlib.lib(BusAtruProtection.obj) : error LNK2019: unresolved external symbol UpdateAtruDiffVoltage referenced in function joeylifcnq
BusAtruProtectionlib.lib(BusAtruProtection.obj) : error LNK2019: unresolved external symbol InitAtruVoltageBuffer referenced in function joeylifcnq
The "unresolved external symbol" error suggests that these variables "UpdateAtruDiffVoltage" and "InitAtruVoltageBuffer" are not defined in the right place. Perhaps these need to come from a header file.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by