Library problems: cannot find x y z

System: Host: maxg-pc-mint Kernel: 5.4.0-100-generic x86_64 bits: 64 Desktop: Cinnamon 5.2.7 Distro: Linux Mint 20.3 Una
PlatformIO Core, version 5.2.5

I have a project folder with some 30 projects in it.
Before the last update, none of these folders had any problems, as in orange triangles with explanation mark in them.

Since the recent update, every folder has these… 150 warnings all in all.

Two questions:

  1. why is it complaining about missing libraries now?

  2. What I also noted, in the past I could add a ‘global’ library; e.g., like Arduino Ethernet, which every project including new ones would recognise. When I now add a library, it asks for which project I want to add this library… and end up with umpteen copies of the same library.

I cannot recall when this changed, but when I started out with PlatformIO, I had the libraries on a shared drive. E.g.,

Workspaces
- PlatformIO
  - Projects
    - Project1
    - Project2
    - ...
  - Libraries
    - Ethernet
    - Time
    - Servo
    - ...

Now the libraires are added to /home/maxg/.platformio/lib/
image

Does the global library function still exist? And how can I achieve this?
Or are libs now directly associated with the individual project?

[edit1]I thought I add one of these c_cpp_properties.json files. I am happy to provide anything else that can be helpful.

//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
    "configurations": [
        {
            "name": "PlatformIO",
            "includePath": [
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/include",
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/src",
                "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/RTC_ID274/src",
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/DallasTemperature_ID54",
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/OneWire_ID1",
                "/home/maxg/.platformio/lib/PubSubClient_ID89/src",
                "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/Ethernet_ID872/src",
                "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
                "/home/maxg/.platformio/packages/framework-arduino-avr/cores/arduino",
                "/home/maxg/.platformio/packages/framework-arduino-avr/variants/mega",
                "/home/maxg/.platformio/lib/Adafruit BusIO",
                "/home/maxg/.platformio/lib/Adafruit GFX Library",
                "/home/maxg/.platformio/lib/Adafruit SSD1306",
                "/home/maxg/.platformio/lib/DS1307RTC",
                "/home/maxg/.platformio/lib/DallasTemperature",
                "/home/maxg/.platformio/lib/EmonLib_ID116",
                "/home/maxg/.platformio/lib/Ethernet/src",
                "/home/maxg/.platformio/lib/Mouse_ID890/src",
                "/home/maxg/.platformio/lib/OneWire",
                "/home/maxg/.platformio/lib/OneWire_ID1",
                "/home/maxg/.platformio/lib/RF24",
                "/home/maxg/.platformio/lib/RF24/utility",
                "/home/maxg/.platformio/lib/Time",
                "/home/maxg/.platformio/lib/Time_ID44",
                "/home/maxg/.platformio/lib/U8g2/src",
                "/home/maxg/.platformio/lib/USBHost_ID885/src",
                "/home/maxg/.platformio/lib/WiFiEsp_ID509/src",
                "/home/maxg/.platformio/lib/WiFi_ID870/src",
                "/home/maxg/.platformio/lib/cactus_io_BME280_I2C",
                "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
                "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/HID/src",
                "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
                "/home/maxg/.platformio/packages/tool-unity",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/include",
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/src",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/RTC_ID274/src",
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/DallasTemperature_ID54",
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/OneWire_ID1",
                    "/home/maxg/.platformio/lib/PubSubClient_ID89/src",
                    "/media/maxg/Data SSD/Data/Workspaces/PlatformIO/Projects/BMS_Mega/.pio/libdeps/megaatmega2560/Ethernet_ID872/src",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/cores/arduino",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/variants/mega",
                    "/home/maxg/.platformio/lib/Adafruit BusIO",
                    "/home/maxg/.platformio/lib/Adafruit GFX Library",
                    "/home/maxg/.platformio/lib/Adafruit SSD1306",
                    "/home/maxg/.platformio/lib/DS1307RTC",
                    "/home/maxg/.platformio/lib/DallasTemperature",
                    "/home/maxg/.platformio/lib/EmonLib_ID116",
                    "/home/maxg/.platformio/lib/Ethernet/src",
                    "/home/maxg/.platformio/lib/Mouse_ID890/src",
                    "/home/maxg/.platformio/lib/OneWire",
                    "/home/maxg/.platformio/lib/OneWire_ID1",
                    "/home/maxg/.platformio/lib/RF24",
                    "/home/maxg/.platformio/lib/RF24/utility",
                    "/home/maxg/.platformio/lib/Time",
                    "/home/maxg/.platformio/lib/Time_ID44",
                    "/home/maxg/.platformio/lib/U8g2/src",
                    "/home/maxg/.platformio/lib/USBHost_ID885/src",
                    "/home/maxg/.platformio/lib/WiFiEsp_ID509/src",
                    "/home/maxg/.platformio/lib/WiFi_ID870/src",
                    "/home/maxg/.platformio/lib/cactus_io_BME280_I2C",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/HID/src",
                    "/home/maxg/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
                    "/home/maxg/.platformio/packages/tool-unity",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=50101",
                "ARDUINO_AVR_MEGA2560",
                "F_CPU=16000000L",
                "ARDUINO_ARCH_AVR",
                "ARDUINO=10808",
                "__AVR_ATmega2560__",
                ""
            ],
            "cStandard": "c11",
            "cppStandard": "c++11",
            "compilerPath": "/home/maxg/.platformio/packages/toolchain-atmelavr/bin/avr-gcc",
            "compilerArgs": [
                "-mmcu=atmega2560",
                ""
            ]
        }
    ],
    "version": 4
}

[/edit1]

I decided to delete all c_cpp_properties.json files in the project directory, given these are automatically created. Opening any project will create a new one, without any errors… solving this problem. Not sure why this happened in the first place.

Leaves the question:
Is there a way to add a library globally rather than per project?

You need to use lib_extra_dirs.

P.S: What is the reason for using global libraries? We don’t recommend this approach and will deprecate it soon.

1 Like

Happy to learn and appreciate the input.
My reason is: I have some 30 Arduino projects / controllers, all of which use the Ethernet library. Adding it globally will affect all 30 projects with one update. Otherwise, when updating the library, it is asking, which project do you want to update, and I have to do this association 30 times. Now add the OneWire or any other library update and I do this another 30 times, and another… not funny.

Maybe while ago, I could simply reference the global Ethernet library in the platformio.ini lib_deps, without the need of actually adding it to the project.

so in the case of the Ethernet library creating a warning (permissive) at compile, but still an eye soar, I have to go into each library folder and correct the file.

I am a beyond beginner programmer and learn as I go; my thinking could be well out of whack :slight_smile: and what I am doing is not good practice. Maybe the reason you deprecate this functionality.
In any case, I read the link and will use lib_extra_dirs, which seems to allow me to achieve the same outcome. Thank you (and stay alive).

I see, in this case just install libraries to the global storage. See pio pkg install — PlatformIO latest documentation

1 Like