Using Relative Path in MPLAB IDE - microchip

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"

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)

Related

Making local project items accessible from the shared projects in VS C++ 2017

I have deb_sets.h in the main project to set debugging options for the whole project.
Shared projects include this file too. However, it will be different in different main projects.
I get a compilation error fatal error: deb_sets.h: No such file or directory in every shared project file which include this file.
Is my idea possible to achieve?
You need to add the #include "deb_sets.h" in all source files that use this header, but if this header file is in another directory, you need to change "Additional Include Directories" (C++\General section) in the project options to set the header file path.

Set path of Header files to avoid using relative paths (VS2015/c++)

H, i'm trying to set my project up so that i can avoid using relative paths for my header files in my project. The reason is that the project is multi-platform and I would like to avoid restructuring each use dependent on which system it's compiled on.
Currently, the header files do not use the correct path way and the only way i can use the includes is if i set relative paths to the files.
E.G.
for my file render.h i want to use:
#include "math/matrix.h" <--- this doesn't work
but
#include "../math/matrix.h" <--this works
What would i be doing incorrectly here for setting up the project?
in the Properties page, i have set up the following
VC++ Directories -> Include Directories -> C:\Game\math
C++ -> General -> Additional Include Directories -> C:\Game\math
If i right click on the .cpp files and go to properties, i have the C\C++ options but the Headers do not.
If your file resides in C:\Game\math\matrix.h, then an Include Directory of C:\Game\math and #include directive of "math/matrix.h", would produce a concatenated result of C:\Game\math\math/matrix.h. You simply need to change your Include Directory to be C:\Game (or your #include to be only "matrix.h").
Also, generally you set include directories per-project, not per source (.cpp) file. The reason that the header files do not have C++ compilation options is that they are not compiled - only the sources are compiled.

Visual Studio does not find include files, but paths are correct

For my project, I am using Visual Studio 2015. I have added to my include path the folder $(ProjectDir)Source. In details view of Include Directories, in the list below with Evaluated value, the correct path is listed. When I copy this path using #include "path/file", it finds the file. Or via Start > Run, it opens the path.
In my project I have a .cpp file which includes the file like usual:
#include <file>.
Still, I am receiving the error: Cannot open include file 'file.h' No such file or directory. Error C1083.
I copied an existing solution which had similar includes and adjusted them accordingly. It works now.

Use external header files in MPLAB X IDE

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.

XCode - #include <map> in ml.hpp : No such file or directory

I'm trying to compile a C++ code (OpenCV) and I'm going to the end. I just have a few "No such file or directory" compile error into XCode 4 on those lines :
#include <map>
#include <string>
#include <iostream>
What may I include to make it find the "files" ?
I don't see.
I use another project based on OpenCV with Objective-C inside for example that pass the compile process with success, files are the same, and I checked all the Build settings lines one after the other, and it's all the same, except the search pathes that are updated to go to my own project folders. Folder architecture is the same...
I've read this link but it doesn't seems to be the solution as I should not have to add code anywhere of change files, since I don't use any of the code and the example project works fine like this. I've just included into one of my .m files, exactly like the example project.
I've just included into one of my .m
files, exactly like the example
project.
If you want to use C++ classes, you must use Objective-C++. Your source files (not your header files, mind - the source files that #include them) must have a .mm extension.

Resources