Using Relative Path in MPLAB IDE

Donotalo picture Donotalo · Mar 29, 2011 · Viewed 7.7k times · Source

My project structure and files are as follows:

project\HAL\hw_lcd.h
project\HAL\hw_lcd.c
project\project\app.c
project\project\workspace.mcp
project\project\workspace.mcw

Where 'project' is a place holder for project name. I'm using MPLAB IDE 8.66 and HI-TECH Compiler 9.81.

I'd like to add hw_lcd.h/c files using relative path to the project. So that if I write #include "HAL/hw_lcd.h" in app.c, then hw_lcd.h will be found from app.c.

I added ../ as include search path (project > build options... > project > directories and search path > include search path) but got following error:

can't open include file "hw_lcd.h": No such file or directory

Then I tried ../HAL as include search path and written #include "hw_lcd.h" in app.c. This also generates the above error.

Is it possible to use relative search path from within MPLAB IDE?

If the #include path itself is relative, then it works:

#include "../HAL/hw_lcd.h"

Answer

Marco van de Voort picture Marco van de Voort · Apr 6, 2011

Not entirely the same, but I always use

            #include "hw_lcd.h"

and then add the header to the project, and in the "add" dialog I select "this file is for this project, use relative path" or something similar.

This works fine. (but has the trouble that if paths (e.g. HAL) change, you need to walk over them, and change them all)