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.
Related
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.
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.
When i run my program in MPLAB. ( Project wizard -> PIC16F877A -> Hi Tech Ansi C Compiler -> RUN )
Error [141] C:\Users\WhyWhy\Desktop\test.c; 1.22 can't open include file "16F877A.h": No such file or directory
Where can i find the header file for the 16F877A?
Chip-specific header files should not be explicitly included in HITECH-C, the documentation clearly states that. Instead, you include the compiler header, which will take care of including the chip-specific file for you:
#include <htc.h>
All you need for this to work is to configure correct chip in the project settings. The 16F877A.h file exists in the compiler directory, but including it directly will throw a warning.
C:\Program Files\HI-TECH Software\PICC\9.70\include
In my case , I have installed HITech Compiler In C:\ Program Files.
You have to know, where have you installed the files of the compiler.
This file is from the compiler, so in your case the Hi Tech you can find here:
C:\Program Files\HIāTECH Software\PICC\\include\
Before you have found the file you have to add in the Header Files folder in the Project window on MPLAB.
And in your code you have to include it
#include <16F877A.h>
I have an Xcode project "App" which references another Xcode project "Lib".
The "Lib" project is generated by Cmake. I use "add_definitions(-DMYDEFINE)" to set a define. This define is used in a .h and a .cpp file in my lib project.
The problem is the header (.h) file. If I use it from within the Lib project, my define is set. If I use the file from my App project, the define is not set (header file of lib is in my include path).
This set/not set happens at the same time, although the header file is guarded with "#pragma once".
I need this define in the header file. Is there a way to organize things such that I can set the define only with Cmake in the Lib project?
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)