Path configuration of library C-scripts for RT-box

Hi,

I have a working simulation where I have included a search path to my custom library, which contains various C-scripts.
The path is for example:
C:/subFolder1/subFolder2/subFolder2/subFolder3/myLib.plecs

In this custom library the C-scripts are using relative paths such as:
…/MySourceFiles/Source.c
…/MySourceFiles/header.h

I can run the simulation in Plecs just fine, but the issue arrises when building the code for the RT box, which doesn’t seems to handle the library search paths?

The plecs model I want to build onto the target is for example located in:
C:/subFolder1/MySimulation.plecs

And I then get a build error in the auto-generated code which is located here:
C:/subFolder1/MySimulation_codegen/source.c

Which is because it now cannot find the path to my original source file located in my custom library.

Is there some way to fix this?
I have multiple linked libraries so I cannot just move MySimulation_codegen/source.c to where the custom library is located.

As you noted, there isn’t a means to add additional include directories when compiling a C-Script. The most straightforward approach would simply be to add these folders into the appropriate location relative to *.c file in the Model_codegen directory.

You can perform basic file manipulations in Octave (or MATLAB if you’re using Blockset). Below is some example code to put in the Model Initialization commands that creates a symlink in the Model_codegen directory to the source files in folder lib.

include_relative_path = 'lib'
model_name = plecs('get','.').Name
src_dir = fullfile(pwd,include_relative_path)
if ~isdir(src_dir)
	error('Could not find src_dir %s',src_dir)
end
dest_dir = fullfile(pwd,[model_name,'_codegen'],include_relative_path)
if ~isdir(dest_dir)
	%# Here I'm using symlinks, but you could just as well copy the file contents
	[stat, msg] = symlink(src_dir,dest_dir)
end