Library cpp file references another library - wont compile

Hi All (newbie alert)

Wonder if anyone can help, Caveat - I am new (tonight) to the PlatformIO environment so it could be I’m just being stupid.

I have ported a couple of project over from the Arduino IDE, some of which work perfectly some wont compile correctly - I am getting an error when referencing an include that is part of another library

i.e. If a library cpp file has an include that references another (installed) library when compiling it fails to find the include. As an example I am using RTClib which is a fork of Jeelab’s DS1307RTC library. Within the RTClib.cpp there is an #include <Wire.h> which is an I2C library.

I get the following error at compile time

.pioenvs/espino/RTClib/RTClib.cpp:4:18: fatal error: Wire.h: No such file or directory

Now of course I can copy the Wire.h file into the RTClib library folder and it complies fine but this appears to be occurring on other libraries whenever the above references appear, I have just used RTClib as an example.

I have tried to rebuild the project C++ index but this doesn’t seem to help

my question is therefore two fold

  1. Is it bad practice to write a library that references another and not include a copy of it within the library folder?
  2. Is there another solution that will search hierarchically through the libraries i use to see if any others are referenced and include those in the copy to the .pioenvs folder prior to compilation?

I know many of you will cringe when I say this (I have caveated im a newbie) but it works fine in the Arduino IDE - I recognise that doesn’t necessarily make it right :slight_smile: But I want to keep my libraries as organised as I can and copying the appropriate .h file to another libraries folder is fraught with risks of version control issues.

Thanks in anticipation

Ric

Hi @rkflyer!
Doesn’t look like you are doing anything wrong. Could you share your project as zip file somewhere?

Hi

It would appear that all is ok, I just happened to be unlucky in the two project I initially converted over had this issue - none of my other projects had the problem. It was because I was using a DateTime function in the RTC library but wasn’t using the I2C element of it, hence no include for the Wire.h in my Main.cpp.

Regardless I am very impressed with your work on the Platformio - Its nice to move away from the Arduino IDE and its quirks.

Regards

Ric