S-Function Builder -- compile all c-files in folder

3 次查看(过去 30 天)
Hi,
I'm using the S-Function Builder block to include custom c-code in a Simulink model. Everything works fine except that I cannot compile all .c-files in a directory without adding them one by one explicitly to the source file list in the "Libraries" pane.
Working Solution:
./TL_s-function/file1.c
./TL_s-function/file1.c
./TL_s-function/file1.c
...
INC_PATH ./TL_s-function/
INC_PATH ./TL_s-function/include/
INC_PATH ./TL_s-function/Parameter/
Desired Solution:
SRC_PATH ./TL_s-function/
INC_PATH ./TL_s-function/
INC_PATH ./TL_s-function/include/
INC_PATH ./TL_s-function/Parameter/
This solution leads to an "error LNK2019: unresolved external symbol" error due to the uncompiled c-files. I thought "SRC_PATH" instructs the mex compiler to compile all c-files in this directory. But it doesn't. Is there any other solution? Thanks.
(I'm using Version 8.1 (R2013.a) on a Windows machine with "Microsoft Software Development Kit (SDK) 7.1" compiler )

回答(2 个)

Huihua Zhao
Huihua Zhao 2018-6-11
I came to a similar problem. It seems that you have to add the directory to "SFCN_DIR" instead. This trick fixes my problem.

Alexander Tuma
Alexander Tuma 2024-2-26
As I understand it, adding a directory with SRC_PATH includes this directory into the search for source files. Therefore the source files can be added without preceding path.
So you can add your source files as if they were in your working directory, but you still have to add all of them.
SRC_PATH ./TL_s-function
file1.c
file2.c

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by