I have a folder with some .h and .c files and I want to use header files in my projects.
I have included them in "Header Files" folder of my project using "Add Existing Item" but when i try to "#include" them compiler(mplabc18\v3.41) say "unable to locate file xyz.h"
So, what should i do to use these files without copying them into the project folder?
Just add the header to the project using the "add" dialog and select "this file is for this project, use relative path" dont remember if it is exac this text but its something like.
After that just do the normal declaration in your file:
#include "your_header.h"
This should work fine.
--UPDATE
To work with the new MPLAB X
Do the follow:
Click on the File-> Project Properties
Select the Conf -> C18 (Global Options) -> mcc18
For XC8, this is under Conf > XC8 compiler
Click on the "..." button of the propertie "Include directories"
Click on "Browse Button"
Locate you project directory
Click on Open, then Ok and Apply
Build your app !
Now it should work.
I know this is an old question, but wanted to add another tip since I just stumbled across it myself. If you go back and forth between Windows and Linux systems, be sure to pay attention to the capitalization in the filename. On Windows, it doesn't matter. However, on Linux, you need to be sure your #include reference has the same capitalization as the actual file.
If the file is saved on disk as 'UARTIO.INC', your include needs to be:
#INCLUDE "UARTIO.INC" **EXACTLY**
If you put it as:
#INCLUDE "UARTIO.inc", or #INCLUDE "uartio.inc"
It will work fine on Windows, but will fail with "Could Not Find Include File" errors on Linux.
Note that setting MPLAB to ignore case sensitivity doesn't matter for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With