Libraries are a huge pain almost all the time

It got almost finished after I pasted the folders into /lib:

In file included from C:\Users\joema.platformio\lib\Adafruit BusIO/Adafruit_I2CDevice.h:1:0,
from C:\Users\joema.platformio\lib\Adafruit BusIO\Adafruit_I2CDevice.cpp:1:
C:\Users\joema.platformio\packages\framework-arduinoespressif32\libraries\Wire\src/Wire.h:98:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int, int)
uint8_t requestFrom(int address, int size, int sendStop);
^
C:\Users\joema.platformio\packages\framework-arduinoespressif32\libraries\Wire\src/Wire.h:93:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint16_t, uint8_t, bool)
uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
^
Archiving .pio\build\esp32dev\lib99d\libAdafruit BusIO.a
Compiling .pio\build\esp32dev\libd72\Adafruit GFX Library\Adafruit_MonoOLED.cpp.o
In file included from lib\Adafruit GFX Library\Adafruit_GrayOLED.cpp:20:0:
lib\Adafruit GFX Library\Adafruit_GrayOLED.h:31:32: fatal error: Adafruit_SPIDevice.h: No such file or directory

The goal posts are moving.

And now that I have BusIO pasted in:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 1.12.4 > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for Adafruit_SSD1306 library in registry
Warning! Library `{'name': 'Adafruit_SSD1306', 'requirements': None}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'name': 'Adafruit_SSD1306', 'requirements': None}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <TimeLib>
|-- <Wire> 1.0.1
|-- <Tone32> 1.0.0
|-- <Adafruit GFX Library> 1.10.0
|   |-- <Adafruit BusIO> 1.4.1
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <Adafruit SSD1306> 2.3.1
|   |-- <Adafruit GFX Library> 1.10.0
|   |   |-- <Adafruit BusIO> 1.4.1
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Archiving .pio\build\esp32dev\lib021\libTimeLib.a
Compiling .pio\build\esp32dev\libba3\Wire\Wire.cpp.o
Compiling .pio\build\esp32dev\libd16\Tone32\Tone32.cpp.o
Compiling .pio\build\esp32dev\lib5a1\SPI\SPI.cpp.o
Archiving .pio\build\esp32dev\lib5a1\libSPI.a
Compiling .pio\build\esp32dev\lib4de\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\esp32dev\lib4de\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Archiving .pio\build\esp32dev\libd16\libTone32.a
Compiling .pio\build\esp32dev\lib4de\Adafruit BusIO\Adafruit_I2CRegister.cpp.o
Archiving .pio\build\esp32dev\libba3\libWire.a
Compiling .pio\build\esp32dev\lib4de\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:3:145: error: ISO C++ forbids declaration of 'Adafruit_I2CRegister' with no type [-fpermissive]
 Adafruit_I2CRegister::Adafruit_I2CRegister(Adafruit_I2CDevice *device, uint16_t reg_addr, uint8_t width, uint8_t bitorder, uint8_t address_width) {
                                                                                                                                                 ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:3:145: error: no 'int Adafruit_BusIO_Register::Adafruit_I2CRegister(Adafruit_I2CDevice*, uint16_t, uint8_t, uint8_t, uint8_t)' member function declared in class 'Adafruit_BusIO_Register'
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::write(uint8_t*, uint8_t)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:14:9: error: '_device' was not declared in this scope
   if (! _device->write(buffer, len, true, addrbuffer, _addrwidth)) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::write(uint32_t, uint8_t)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:29:9: error: '_bitorder' was not declared in this scope
     if (_bitorder == LSBFIRST) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'uint32_t Adafruit_BusIO_Register::read()':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:49:10: error: '_bitorder' was not declared in this scope
      if (_bitorder == LSBFIRST) {
          ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::read(uint8_t*, uint8_t)':
Compiling .pio\build\esp32dev\libd72\Adafruit GFX Library\Adafruit_GFX.cpp.o
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:62:9: error: '_device' was not declared in this scope
   if (! _device->write_then_read(_buffer, 1, buffer, len)) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::read(uint16_t*)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:73:7: error: '_bitorder' was not declared in this scope
   if (_bitorder == LSBFIRST) {
       ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: At global scope:
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:105:106: error: ISO C++ forbids declaration of 'Adafruit_I2CRegisterBits' with no type [-fpermissive]
 Adafruit_I2CRegisterBits::Adafruit_I2CRegisterBits(Adafruit_I2CRegister *reg, uint8_t bits, uint8_t shift) {
                                                                                                          ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:105:106: error: no 'int Adafruit_BusIO_RegisterBits::Adafruit_I2CRegisterBits(Adafruit_I2CRegister*, uint8_t, uint8_t)' member function declared in class 'Adafruit_BusIO_RegisterBits'  
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:117:6: error: prototype for 'void Adafruit_BusIO_RegisterBits::write(uint32_t)' does not match any in class 'Adafruit_BusIO_RegisterBits'
 void Adafruit_I2CRegisterBits::write(uint32_t data) {
      ^
In file included from lib\Adafruit BusIO/Adafruit_I2CRegister.h:1:0,
                 from lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:1:
lib\Adafruit BusIO/Adafruit_BusIO_Register.h:66:8: error: candidate is: bool Adafruit_BusIO_RegisterBits::write(uint32_t)
   bool write(uint32_t value);
        ^
*** [.pio\build\esp32dev\lib4de\Adafruit BusIO\Adafruit_I2CRegister.cpp.o] Error 1
==================================================================================================== [FAILED] Too

I downloaded fresh zip files for all the libraries in this program and saved them to the /lib folder, and it compiled all the way.

And then it started raising errors:

libraries yes

Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\libba3\Wire\Wire.cpp.o
Compiling .pio\build\esp32dev\libd16\Tone32\Tone32.cpp.o
Compiling .pio\build\esp32dev\lib5a1\SPI\SPI.cpp.o
In file included from C:\Users\joema.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/pthread.h:33:0,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\xtensa-esp32-elf\bits\gthr-default.h:35,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\xtensa-esp32-elf\bits\gthr.h:148,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\ext\atomicity.h:35,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\bits\basic_string.h:39,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\string:52,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\random:40,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:66,
from c:\users\joema.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62,
from C:\Users\joema.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:142,
from src\main.cpp:1:
lib\Time/time.h:1:2: warning: #warning “Please include TimeLib.h, not Time.h. Future versions will remove Time.h” [-Wcpp]
#warning “Please include TimeLib.h, not Time.h. Future versions will remove Time.h”
^
In file included from src\main.cpp:3:0:
lib\Time/Time.h:1:2: warning: #warning “Please include TimeLib.h, not Time.h. Future versions will remove Time.h” [-Wcpp]
#warning “Please include TimeLib.h, not Time.h. Future versions will remove Time.h”
^
src\main.cpp: In function ‘void loop()’:
src\main.cpp:67:3: error: ‘serial’ was not declared in this scope
serial.begin(9600);
Archiving .pio\build\esp32dev\lib5a1\libSPI.a
^
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
==================================================================================================== [FAILED] To

The script is running. Lights are coming on. Buzzers aren’t buzzing yet, but I haven’t been able to upload any changes due to these new errors, which have appeared since I uploaded the script that doesn’t work now.

Serial?

Really?

But serial is so common. It has to be declared???

And the library folder is Time. TimeLib.h and Time.h are in that folder.

Look again! The error has “serial” not “Serial”. In main.cpp at line 67, column 3. Been there done that. I usually call it “Serail”. I do it frequently.

It’s a warning. You’ll find it in Time.h at line 1.

It’s telling you that Time.h is now renamed to TimeLib.h and that any code using the former should, rather urgently, change to the latter. Nothing to do with PlatformIO, everything to do with the library’s source code. Just change your #include as instructed in the message.

Yes. It runs quietly in the background.

It’s not a link, you are telling it where to install the library from. As I said earlier, just try a smple sketch. “Link” to a library, compile, look in .pio/build/<ENVIRONMENT>/libnnn/<LIBRARY_NAME>/<FRAME_WORKNAME> you should find the “linked” library has been installed.

See above, the compiler doesn’t even need to get out of bed! :grin:

No quotes, just as I explained. No spaces around the ‘=’ though. If you have more than one library, either:

; Comma space between libraries
lib_deps=Lib1, Lib2, ...

Or:

; separate lines, tab or spaces for indent.
lib_deps=
   Lib1
   Lib2
   ...
  • The main sources go in src.
  • The main headers go in include, but the can go in src.
  • Your class headers and sources can go in src, I put mine in lib/<SOME_NAME>.
  • Dowloaded libraries go where lib_deps puts them. Or, where the GUI (PlatformIO Home) puts them – you and I don’t worry about them.

This is why you let lib_deps look after them. :wink:

If you are online probably although I noticed I was still using Servo 1.1.6 when 1.1.7 was available. I had lib_deps=servo@^1.1.6.

Why would you want to dowload the library that is in lib_deps? Itgets downloaded on the first compile. Look at my ecplanation again, the section called Where’s my Library All the library source, examples etc are already downloaded.

I think the library is called time - at least you said so above. The header file it now wants you to use is TimeLib.h.

No idea, sorry. A file is missing. Adafruit_GFX.h.

Yes.It.Does! It really does. Trust me, I’m not a politician!

Stop putting stuff in there. Stop downloading libraries manually. Let the system look after them properly.

You are struggling, that’s ok. Libraries are giving you grief. Stop trying to write complicated code with what appears to be potentially incorrectly written (structured) libraries.

Start with a simple sketc, one library. You dont even have to upload it, just get it to compile.

Don’t download anything.

Search for the required library. Use the GUI.

Get the simple stuff working. Look around afterwards, see what has been installed for you. Make notes. Anything to help you get your head around where the problems are.

HTH

Cheers,
Norm.

I caught the lowercase serial, and I figured out Time.
I deleted everything in /lib and redid the lib_deps, and it compiled just fine.

I want to have all the associated files in hand when I go to make an actual machine. I want to be able to refer to the thing as it was.

Excellent news.

Your associated files are in the two locations I posted previously.

<PROJECT_HOME>/.pio/libdeps/<ENVIRONMENT>/<LIBRARY_NAME>/ for the sources, and, <PROJECT_HOME>/.pio/build/<ENVIRONMENT>/libnnnn<LIBRARY_NAME>/<FRAMEWORK_NAME> after compiling.

So, to archive the complete project, and all files, just zip up the project’s folder.

Cheers,
Norm.

Doesn’t work.

I think you have so many threads open, you’ve replied to the wrong one. The above quote is from this thread.

But now you say,

With a screen shot of the GFX library. You’re on the wrong thread.

I’ll see you back on your other thread - about the tone() function.

Cheers,
Norm.

Wrong.

Time, not TimeLib
Adafruit SSD1306, not Adafruit_SSD1306

You are putting the wrong names in.

The warning you then get from the Time library is because… you did #include <Time.h> instead of #include <TimeLib.h> - time.h is a standard library included with the compiler, hence that name can’t be used for 3rd party libraries.

‘serial’ was not declared in this scope - C++ is case sensitive… where is the capital S?

Although you might have realised this by now, or not. It’s hard to tell with you jumping between threads, and then back to old versions of code. :man_facepalming:

This morning, I redid a buzzers/.LED thing for Uno, since I’m not going to get a tone out of the WeMos. I was unable, and the message said that there were too many libraries named Arduino, so it chose the first one. The first one has some specialty suffix.

I overrwrote a nice BME680 program on the WeMos, so I was going to put it back. That project was also an experiment, to see if libraries placed in the src folder would be recognized. They weren’t.
Today I emptied all the folders and wrote in lib_deps instead. It’s squiggling Adafruit_BME680 too.
I just installed BME680 and Adafruit_Sensor libraries globally using the PIO library addition utility, because lib_deps didn’t work either.


compilation terminated.
*** [.pio\build\wemos_d1_mini32\libd1e\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o] Error 1
In file included from lib\Adafruit GFX Library\Adafruit_MonoOLED.cpp:20:0:
lib\Adafruit GFX Library\Adafruit_MonoOLED.h:31:32: fatal error: Adafruit_SPIDevice.h: No such file or directory


If this is for the uno, please zip up the entire project folder (the one with platformio.ini), with the subdirectories, and email it to me. If that is permitted.

I’ll see what I can see for you.

Norman (at) dunbar (hyphen) it.co (dot) uk.

Thanks.

Cheers,
Norm.

Morning @monsterthews,

I have received your zip file, thanks. I’ve commented over on your latest thread on this matter, on how I managed to compile your Uno version.

It’s at Way too sick of unreliable library stuff - #5 by NormanDunbar for anyone watching!

Cheers,
Norm.

1 Like

I must say that IMHO using names is quite unfortunate and it’s error prone.
The best is to just go to the library and copy the whole github URL with .git at the end. That way you are 100% sure of what you are doing. And it also leaves you the open possibility to use a certain branch adding #BRANCH_NAME at the end.

As for Adafruit GFX I also find that is giving errors, best take is to make your own fork and use that. That way you can make sure that even if they update something and add Gray display X it won’t break your own sketch.

1 Like

Hi @martinberlin,

Given how many libraries named “servo” there are, for example, I’m surprised that the correct one was ever found! However, now that version 5.0 allows qualified names, things should be better.

We can still use the library ID of course, and as you say, a link to GitHub. Lots of options.

I’m not using any of the stuff above, I was helping @monsterthews who has been frustrated by libraries and struggling a bit to get them to work properly for him. Hopefully things are clearer now.

Cheers,
Norm.

1 Like

I did not explore the .git option, because the options were all presented as equivalent and lib_deps is super simple. If it works, it’s really perfect. Libraries are baggage. I’ve only now, since finding the badly-made Tone32, started looking at actually using a library- forget fixing a library.

I think this thread ends here. I’ve tried to come at the library problem from as many angles as possible to try to get a 3-D understanding of what’s supposed to be happening. There is something wrong. There is a reason why my experience is unexpected. There will be a grand unified libraries post.