Error while compiling a header file

Hello All,
I imported a Global function library containing a header file (GlobalFunction.h) and .c file (GlobalFunction.c) into a project

image

which is then included into my code as "#include “GlobalFunction.h”.

image

I can access this header file (GlobalFunction.h) by rightclicking and opening “GlobalFunction.h”

image

However, when I compile the project, it throws an Error with description “fatal error: GlobalFunction.h”: No such file or directory.

Can someone please guide me what could possibly be done in order to get rid of this error?

PS: This GlobalFunction library file is already added to Library Objects in Cpu.sw

Thanks in advance.

Hi Syed,

The reason you’re seeing that error is that the compiler isn’t able to find the .h file from the include reference you’ve given. The simplest fix is to add the location as an additional include directory. To do this:

  1. Open the Project->Change Runtime Versions window (this is just a quick way to open the configuration properties)
  2. Select the Build tab
  3. Towards the bottom is a box for adding “Additional include directories”. Select the next empty line in that box and double-click. You can type in the location of the .h file here or use the three dots to select it in the file explorer.

Another option would be to use the relative file path in the include statement, but that gets a little messy.

If you’re interested, here is the list of places the compiler checks when it sees an include statement. Libraries created within Automation Studio (i.e. from the Toolbox) generally put their .h files in the Temp/Includes directory of the project. If you make your own .h file, you’ll need to tell the compiler how to find it.

1 Like

Hi Marcus,

Greetings!

Many thanks for your response. I already got rid of that fatal error the same way you just suggested.

1 Like