# Using header file in C-script

**URL:** <https://forum.plexim.com/t/using-header-file-in-c-script/1057>\
**Category:** PLECS\
**Tags:** c-script\
**Created:** [September 15, 2021, 6:06am UTC](https://forum.plexim.com/t/using-header-file-in-c-script/1057 "2021-09-15T06:06:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Guerreiro](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@Marco\_Guerreiro](https://forum.plexim.com/u/Marco_Guerreiro)\
**Post date:** [September 15, 2021, 6:06am UTC](https://forum.plexim.com/t/using-header-file-in-c-script/1057/1 "2021-09-15T06:06:00Z")

</div>

I’m trying to run a simulation where I have a C-script block, and I want to include a “.h” file containing only function prototypes.

Here’s a small setup showing this problem.

On the same folder as the simulation file, I have a “controller.h” file and a “controller.c” file. The “controller.h” file only contains the prototype for a function called “control”. The function itself is defined in the “controller.c” file.

In my C-script block, I call the “control” function. The simulation works when I include the “controller.c” file in the C-script “Code Declarations” section, but it does not work if I include the “controller.h” file, the header file containing the function’s prototype. In this case, I get an error telling me that the function “control” is undefined.

What I am missing?

I have attached a simple simulation example and the header and source files.

[ptest.plecs](https://forum.plexim.com/uploads/short-url/5ads6Z2vSCZwhFeSDaid3sYV616.plecs) (10.6 KB)

[controller.h](https://forum.plexim.com/uploads/short-url/rdyIMa1PE5dwLz6pEGU6KjsiPoV.h) (34 Bytes)

[controller.c](https://forum.plexim.com/uploads/short-url/yKJpmEDE5XOMp2mPVYDIKhdjqGC.c) (134 Bytes)

---

<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:** [September 16, 2021, 11:21am UTC](https://forum.plexim.com/t/using-header-file-in-c-script/1057/2 "2021-09-16T11:21:23Z")

</div>

With the PLECS C-Script block you cannot link against external libraries, so you must include your external code as source code. In other words, you must include the “controller.c” file in the Code Declarations section, as you have done so far.

---

<div class="post-metadata">

**Author:** ![Marco\_Guerreiro](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@Marco\_Guerreiro](https://forum.plexim.com/u/Marco_Guerreiro)\
**Post date:** [September 17, 2021, 3:46am UTC](https://forum.plexim.com/t/using-header-file-in-c-script/1057/3 "2021-09-17T03:46:04Z")

</div>

I see. Thank you for your reply.

I would be great, though, if we could link against external libraries. But I must imagine it is probably not that simple.
