Hello,
I'm trying to compile a program that has header files within 2 folders of the current path.
Something like this,
#include <stdbool.h> #include <stdint.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_sysctl.h" #include "inc/hw_types.h" #include "inc/hw_uart.h" #include "driverlib/debug.h" #include "driverlib/interrupt.h" #include "driverlib/uart.h"
I have header files within inc folder and driverlib folder. Each file within these folders were added to the Source group.
After going through a few threads on the forum I also tried adding my include paths at, Projects- Options for Target-c/c++ tab-Include paths {.\driverlib;.\inc}
Despite all this I'm still receiving compiler errors, such as
driverlib\lcd.c(50): error: #5: cannot open source input file "inc/hw_memmap.h": No such file or directory
What is the best course of action?
Thank you
Note that you need to be careful with #include "non-absolute-name.h" for includes unless the compiler have been given an absolute include search path to the parent directory.
Else you can get a situation where "<projectdir>/main.c" looks for "<projectdir>/driverlib/hw_memmap.h" "<projectdir>/driverlib/lcd.c" looks for "<projectdir>/driverlib/driverlib/hw_memmap.h"
within 2 folders of the current path.
Note that the current working directory might not be what you think it is. For a uVision project the CWD is where the uVision project files are, not where the C sourcefile is.
And adding these {.\driverlib;.\inc} to the include search path makes no sense. This will search your header "driverlib/debug.h" using the relative filenames ".\driverlib\driverlib\debug.h" and ".\inc\driverlib\debug.h". That's surely not where it actually is, right? Your include search path should thus be {.} instead. Or if my suspicions about your working directory are correct, it may have to be {..\..\source_root} or something like that.
In practice it's usually best to avoid path specifiers in your project-specific #include directives altogether. Bad things ensue if you ever have more than one header with the same name, in different directories of your source tree. Different source modules may then find different files while asking for the same named header, and you have rather little control over which one they'll get.
Thank you Westermark and Broeker.
You were right. Along with .\driverlib;.\inc, I added ./ as well, and now it compiles successfully. :-)
Though, there are a few more compile errors. If you gett any idea to get past them, kindly let me know.
I'm basically trying to interface the MPU-6050 inertial measurement unit to my Tiva launchpad using the tivaware api.
This is some of the compiler errors I'm facing,
i2cm_drv.h(458): error: #20: identifier "inline" is undefined inline uint_fast8_t i2cm_drv.h(458): error: #101: "uint_fast8_t" has already been declared in the current scope inline uint_fast8_t mpu6050.h(131): error: #757: variable "uint_fast8_t" is not a type name extern uint_fast8_t MPU6050Init(tMPU6050 *psInst, tI2CMInstance *psI2CInst, mpu6050.h(131): error: #20: identifier "tMPU6050" is undefined extern uint_fast8_t MPU6050Init(tMPU6050 *psInst, tI2CMInstance *psI2CInst, mpu6050.h(132): error: #757: variable "uint_fast8_t" is not a type name uint_fast8_t ui8I2CAddr,
I have already included all the driver files for the tivaware (driverlib) and the relevant sensor library files. Do you think this is a case of missing header files or something to do with my keil configuration?