# Include paths in C-Scripts

**URL:** <https://forum.plexim.com/t/include-paths-in-c-scripts/779>\
**Category:** PLECS\
**Tags:** c-script\
**Created:** [June 4, 2020, 5:11am UTC](https://forum.plexim.com/t/include-paths-in-c-scripts/779 "2020-06-04T05:11:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandro\_Calligaro](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Sandro\_Calligaro](https://forum.plexim.com/u/Sandro_Calligaro)\
**Post date:** [June 4, 2020, 5:11am UTC](https://forum.plexim.com/t/include-paths-in-c-scripts/779/1 "2020-06-04T05:11:37Z")

</div>

Hi all,

I am using external code (header and source files for specific functions) in a C-Script, e.g.

#include \<my\_functions.c\>

It all works when the included file is in the same directory as the simulation model. If the files are more than a couple, it would be nice to have them in a separate folder, but so far I couldn’t manage to use a relative path like

#include “./Lib/my\_functions.c”

(same with backslash and/or \<\> brackets).

Is there any way to use relative paths in this context?

Thanks!

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [June 8, 2020, 10:06am UTC](https://forum.plexim.com/t/include-paths-in-c-scripts/779/2 "2020-06-08T10:06:14Z")

</div>

Hi Sandro,

This is possible. Perhaps your directory structure doesn’t match how you are entering the relative paths. Attached is a simple example that works. The external C files are in the “lib” folder that is in the same directory as the PLECS model.If the files were structured differently, say “proj/models/scriptTest.plecs” and “proj/lib/my\_functions.c” then you would change the include to: #include "…/lib/my\_functions.c"Hope this helps address your issue. Regards,Bryan

[scriptTest.zip](https://forum.plexim.com/uploads/short-url/7FioTlSKyfd4xnwFOeIH84q1kg7.zip) (3.41 KB)

---

<div class="post-metadata">

**Author:** ![Sandro\_Calligaro](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Sandro\_Calligaro](https://forum.plexim.com/u/Sandro_Calligaro)\
**Post date:** [June 9, 2020, 4:11am UTC](https://forum.plexim.com/t/include-paths-in-c-scripts/779/3 "2020-06-09T04:11:32Z")

</div>

Thanks Bryan,

your model works. I modified my #include path accordingly, and it works now.

I’m a bit surprised that to make it work we must not use “./” nor "." before the subdirectory name, although dot seems to be standard (both in UNIX and DOS) for referencing the current directory…

Best,

Sandro
