MATLAB: Missing headerfile “candef.h” while trying to generate code for raspberry pi

cansimulink

I get the following error when i try to simulate in external mode on my raspberry pi Bv2. Im using CAN blocks from the Vehicle Network Toolbox. Simulating in "normal" – mode works perfectly. Do i need to include the headerfile in a manual way or why is it missing on my target?
Error executing command "touch -c /home/pi/Controller_xPC_ref_ert_rtw/*.*;make -f Controller_xPC_ref.mk all -C /home/pi/Controller_xPC_ref_ert_rtw". Details:
STDERR: In file included from Controller_xPC_ref.c:20:0: Controller_xPC_ref.h:29:21: fatal error: can_def.h: No such file or directory
#include <can_def.h> ^
compilation terminated.
make: *** [Controller_xPC_ref.c.o] Error 1
STDOUT:
make: Entering directory '/home/pi/Controller_xPC_ref_ert_rtw' echo "###
Compiling "Controller_xPC_ref.c" ..." ### Compiling Controller_xPC_ref.c ... gcc -c -MMD -MP -MF"Controller_xPC_ref.c.dep" -MT"Controller_xPC_ref.c.o" -O0 -DMODEL=Controller_xPC_ref -DNUMST=3 -DNCSTATES=0 -DHAVESTDIO -DON_TARGET_WAIT_FOR_START=1 -DONESTEPFCN=1 -DEXT_MODE=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0
-DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DRT -DUSE_RTMODEL -DERT -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__
-DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=64 -DONESTEPFCN=1 -DEXT_MODE=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0
-DALLOCATIONFCN=0 -DTID01EQ=0 -DON_TARGET_WAIT_FOR_START=1 -DRT -DUSE_RTMODEL -DERT -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=64 -DMODEL=Controller_xPC_ref -DNUMST=3 -DNCSTATES=0 -DHAVESTDIO -I./ -o "Controller_xPC_ref.c.o" "Controller_xPC_ref.c" Controller_xPC_ref.mk:510: recipe for target 'Controller_xPC_ref.c.o' failed make: Leaving directory '/home/pi/Controller_xPC_ref_ert_rtw'

Best Answer

Since simulation in "normal" mode works fine, so it seems like you're using blocks which might be incompatible for code generation, causing error in external mode.
I'd recommend you to verify the same.
The Simulink Block Data Type Support Table describes the data types that are supported by the blocks in the main Simulink and Fixed-Point libraries. The table also identifies blocks that are suitable for production code generation. You can view the table by typing the MATLAB command:
>> showblockdatatypetable
Alternatively, you can open an existing model or create a new model, then in the model window click on Help -> Block Support Table.
Related Question