Simulink Code-Generation: 'undefined reference to...'

17 views (last 30 days)
Hi Guys, I am using the Matlab Function Block to to write driver software to communicate with the TinyCAN I-XL Hardware, which is connected to my Raspberry Pi. In the Function Block I call to Wrapper functions "my_init_func" and "my_tiny_can_func". "my_init_func" again contains API-functions that are necessary to initalize the TinyCAN Board (e.g. "LoadDriver", "CanSetSpeed", ...). "my_tiny_can_func" again contains functions that write to and read from the can bus (e.g. "CanTransmit", "CanReceive",...). All this Code is written into a C-File "TinyCAN_read_Test.c". This C-File includes "config.h", "global.h" and "can_drv.h" ,which I copied into my Matlab-Directory in which the C-File is located. I also copied "can_drv.h", "can_drv_config", "can_drv_ex.h", "can_drv_linux.c", "can_types.h", "config.h", "global.h", "linux_util.h" and "mhs_can_drv.c" into this Matlab-Directory. I executed set_param('RaspiTinyCANDriverBlock','CustomSource',fullfile('..','09_TinyCAN_test','TinyCAN_read_Test.c')) to make sure, Simulink finds the C-File.
When I try to build the Simulink-Model with the Matlab-Function-Block, I get these errors: STDERR: TinyCAN_read_Test.c.o: In function `my_init_func': TinyCAN_read_Test.c:(.text+0x14): undefined reference to `UtilInit' TinyCAN_read_Test.c:(.text+0x1c): undefined reference to `LoadDriver' TinyCAN_read_Test.c:(.text+0x58): undefined reference to `CanExInitDriver' TinyCAN_read_Test.c:(.text+0x98): undefined reference to `CanExCreateDevice' TinyCAN_read_Test.c:(.text+0xe0): undefined reference to `CanDeviceOpen' TinyCAN_read_Test.c:(.text+0x128): undefined reference to `CanSetSpeed' TinyCAN_read_Test.c:(.text+0x140): undefined reference to `CanSetMode' TinyCAN_read_Test.c:(.text+0x150): undefined reference to `CanDeviceClose' TinyCAN_read_Test.c:(.text+0x158): undefined reference to `CanExDestroyDevice' TinyCAN_read_Test.c:(.text+0x15c): undefined reference to `CanDownDriver' TinyCAN_read_Test.c:(.text+0x160): undefined reference to `UnloadDriver' TinyCAN_read_Test.c.o: In function `my_tiny_can_function': TinyCAN_read_Test.c:(.text+0x264): undefined reference to `CanTransmit' TinyCAN_read_Test.c:(.text+0x2c8): undefined reference to `CanGetDeviceStatus' TinyCAN_read_Test.c:(.text+0x32c): undefined reference to `CanSetMode' TinyCAN_read_Test.c:(.text+0x354): undefined reference to `CanReceive' TinyCAN_read_Test.c:(.text+0x448): undefined reference to `KeyHit' TinyCAN_read_Test.c:(.text+0x464): undefined reference to `CanDeviceClose' TinyCAN_read_Test.c:(.text+0x46c): undefined reference to `CanExDestroyDevice' TinyCAN_read_Test.c:(.text+0x470): undefined reference to `CanDownDriver' TinyCAN_read_Test.c:(.text+0x474): undefined reference to `UnloadDriver' collect2: error: ld returned 1 exit status make: * [../RaspiTinyCANDriverBlock.elf] Error 1
When I put "api_calls.h" into my Matlab-Directory and add #include api_calls.h into my C-File, I get: Function TAR tried to add two files as "global.h".
Any help would be greatly appreciated, thank you!

Answers (0)

Categories

Find more on Simulink Supported Hardware 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!