Reputation: 1
I'm having issues with getting #include to actually include libraries. The compiler software doesn't want to recognize the library.
Hi Folks! I'm a somewhat new programmer. I'm currently trying to get a library from github to work (liblightmodbus) in the microchip studio compiler. I've followed the instructions of adding include path Microchip Studio, Toolchain Linking I've downloaded the .zip and unpacked it to the debug folder within the project I'm working with. Then in the solution explorer i clicked "Show all Files" and right clicked the downloaded project and "Include in Project"
Despite this once I compile the program it returns error about
lightmodbus/lightmodbus.h: No such file or directory
and flags the lines whith
#include <lightmodbus/lightmodbus.h>
What have I missed?
Upvotes: 0
Views: 641
Reputation: 332
Your include line uses <> brackets. This informs the pre-processor to go and search the toolchain directories, as defined by Atmel/Microchip Studio.
When including files, you can choose to use either
#include "file.c"
or
#include <file.c>
This post describes the behaviour is much more detail.
In addition, unpacking the library to the debug folder is likely to be your second problem (for the reasons described in the linked post). You should instead unpack it to directory containing the rest of your source, or a sub directory of there, and include using "".
Upvotes: 0