2

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"
Donotalo
  • 12,748
  • 25
  • 83
  • 121

1 Answers1

0

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)

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • Most likely the absolute path to the directory that contains the file is added in "Include Search Path" from "Build Options" for your project. – Donotalo Apr 06 '11 at 19:04
  • It isn't. It is only one level down from the project dir though. And never let the IDE choose automatic, always "use relative". Not unlike yours, just that it is called INCLUDE16 instead of HAL. – Marco van de Voort Apr 10 '11 at 13:40
  • Your case it is `down`. For me it is `up` from project level. – Donotalo Apr 10 '11 at 15:41
  • It's ..\include16 relative to the project dir. So up. – Marco van de Voort Apr 10 '11 at 19:10
  • You mean ..\include16 is added to the include search path? – Donotalo Apr 11 '11 at 00:40
  • Sorry, yes indeed I found the whole dir was added in the include search path. Relative though (..\include16) – Marco van de Voort Apr 11 '11 at 07:30
  • Why does this works for you but not for me? What is your OS and what version of MPLAB you are using? – Donotalo Apr 11 '11 at 15:51
  • Multiple versions, mainly mplab 8.63 using the dspic33 microchip compiler (which is gcc based) on windows XP,Vista and W7. (same checkout on multiple PCs). The resulting repository is not dependant on where it is checked out, and I assume that is the bit you are after. Note that the includefile path is set at the project level. – Marco van de Voort Apr 12 '11 at 11:24