PlatformIO Community

Library install problem

Hi, any help with sorting this much appreciated.

I have a project which uses the liquid crystal library and it throws the error below. I have tried searching the pio library service for ‘wire.h’ or just ‘wire’ and it comes back with 585 offerings. Is there a better way to do this please?

**************************************************************

    #include <Wire.h>
             ^~~~~~~~
compilation terminated.
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\I2CIO.cpp.o] Error 1
====================================================================================== [FAILED] Took 3.14 seconds ======================================================================================
The termin

Hi @paulskirk53

I created a project for the Mega2560 with only the following:

#include <Arduino.h>
#include <Wire.h>

void setup() {
}

void loop() {
}

It compiles just fine. I do get errors if I forget to add in the #include <Arduino.h> – have you got that in your source?

Does your setup compile the above code or does it still error out? If there are still errors, can you post the output from the compiler please. Thanks.

Also, what’s in your platformio.ini? Mine is the default one created for a new project:

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino

The Wire library should be part of the framework for the Arduino boards, assuming that you are using that framework.

Cheers,
Norm.

PlatformIO has a quirk where if you don’t include a library in the main source file, it’s sub-dependencies are not found correctly. Please place a #include <LiquidCrystal_I2C.h> in your src/main.cpp (or similiar).

“Wire” is the I2C base library in the Arduino core, you should not install one from the PlatformIO registry for it. Remove the .pio folder and remove any reference to an external Wire library pulled from the registry from the platformio.ini. If anything, you can reference its usage by adding just Wire to the lib_deps, PlatformIO will find it in the libraries/ folder of the Arduino core then.

1 Like

ok, many thanks for replies. I have a dev machine and an operations machine. The project is version controlled on github. The code in question compiles fine on my dev machine, but the error occurs on the operations machine.

On the operations machine, I just cloned the github repo. Any changes to code happen on the dev machine only and I pull the commits on the operations machine from the git remote. The only reason for having the source code on the operations machine is in case I wanted to amke a change in the field on the fly as it were, and this is what happened on the occasion when compile failed. I made a small change to code on the operations machine and to my surprise the ‘wire’ error came up.

So, when managing the repo, do I need to include files other than this lot shown below?

Many thanks for help.

image

also Max, given what you’ve said, I have this liquid crystal in my Two_Way_Radio_Master.h file:

#pragma once
#include <Arduino.h>
#include <LiquidCrystal.h>


void lcdprint(int col, int row, String mess);
bool validate_the_response(String receipt);
void sendViaBluetooth(String textToSend);
void sendViaASCOM(String textToSend);

and the code compiles on the dev machine without an #include <LiquidCrystal.h> in the src/main.cpp

Which change?

Is C:\Users\<user>\.platformio\packages\framework-arduino-avr\libraries\Wire\src\Wire.h present?

The change to code on the ops m/c was to a constant in the code which defines number of steps for a stepper motor. The code hasn’t been compiled on the machine previously, only on the dev machine. However, the code is supposedly identical (as per github remote).

The ops machine is on a remote site now, so I won’t be able to check if C:\Users\<user>\.platformio\packages\framework-arduino-avr\libraries\Wire\src\Wire.h present until Weds. I’ll reply again then.

I’m guessing it won’t be as looking at my github repo image in the previous post, C:\Users<user>.platformio\packages\ is not part of the repo. But also I’m thinking I wouldn’t want it to be? I just need to version control my own code and PIO pulls in stuff as necessary?

thanks.

Yes, PlatformIO will pull the Arduino core by itself, but I’m just checking if the remote machine may have a corrupted (?) version of it.

Another thing is to check whether both machines are running the same PlatformIO core version (pio --version in the CLI).

ok, thanks, I will check tomorrow and report back.

OK , so I guess I should mention in case its relevant that on the ops machine VScode is installed on a removable USB3 diskdrive which Windows allocates as Drive D: on my machine.

I looked for C:\Users\<user>\.platformio\packages\framework-arduino-avr\libraries\Wire\src\Wire.h and it does exist. However, should I be looking for it on D:…etc If so, it’s not there, just D:\Users\Paul\MicrosoftVS Code. I’ve probably installed PIO / VSCode incorrectly. Perhaps I need to specify a path or reinstall properly?

thanks for help.

That’s not necessary a problem. What does pio system info report? For it does (among other things)

PlatformIO Core Directory   C:\Users\Max\.platformio

if PlatformIO was properly installed in the D: drive, that should also appear there.

PIO system info gives this :

PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-Master-Radio> pio system info
--------------------------  -----------------------------------------------------
PlatformIO Core             5.2.5
Python                      3.9.8-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp1252
PlatformIO Core Directory   C:\Users\Paul\.platformio
PlatformIO Core Executable  C:\Users\Paul\.platformio\penv\Scripts\platformio.exe
Python Executable           C:\Users\Paul\.platformio\penv\Scripts\python.exe
Global Libraries            0
Development Platforms       2
Tools & Toolchains          6
--------------------------  -----------------------------------------------------

PIO is not on drive D: but VSCode is.

thanks.

Ah but projects on a different drive should be no problem.

Try removing the .pio folder again for a “clean” and then build again on the remote machine. Does it fail with the same problem?

What’s the current full platformio.ini?

pio.ini is below:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
upload_port = COM8
monitor_port = COM8
lib_deps = fmalpartida/LiquidCrystal@^1.5.0

[platformio]
description = The Radio Master

having removed the .pio folder, the core has reinstalled. When comoiling I now get this:

Executing task: C:\Users\Paul\.platformio\penv\Scripts\platformio.exe run <

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR (3.4.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <LiquidCrystal> 1.5.0
Building in release mode
Compiling .pio\build\megaatmega2560\src\Two_Way_Radio_Master.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\FastIO.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\I2CIO.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\LCD.cpp.o
*** [.pio\build\megaatmega2560\src\Two_Way_Radio_Master.cpp.o] Error 1
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\FastIO.cpp.o] Error 1
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\I2CIO.cpp.o] Error 1
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\LCD.cpp.o] Error 1
====================================================================================== [FAILED] Took 2.77 seconds ==

The compiler got damaged or antivirus is acting up. Try removing C:\Users\Paul\.platformio\toolchain-avr and rebuilding. If in doubt, remove the entire C:\Users\Paul\.platformio\ folder and rebuild the project.

interesting, C:\Users\Paul\.platformio\toolchain-avr did not exist, so I deleted C:\Users\Paul\.platformio\

still get this:

Executing task: C:\Users\Paul\.platformio\penv\Scripts\platformio.exe run <

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR (3.4.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <LiquidCrystal> 1.5.0
Building in release mode
Compiling .pio\build\megaatmega2560\src\Two_Way_Radio_Master.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\FastIO.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\I2CIO.cpp.o
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
Compiling .pio\build\megaatmega2560\libaf5\LiquidCrystal\LCD.cpp.o
*** [.pio\build\megaatmega2560\src\Two_Way_Radio_Master.cpp.o] Error 1
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\FastIO.cpp.o] Error 1
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\I2CIO.cpp.o] Error 1
'avr-g++' is not recognized as an internal or external command,
operable program or batch file.
*** [.pio\build\megaatmega2560\libaf5\LiquidCrystal\LCD.cpp.o] Error 1
====================================================================================== [FAILED] Took 2.82 seconds ===
	


Sorry I meant C:\Users\Paul\.platformio\packages\toolchain-avr there.

Hmm this shouldn’t be happening if the PlatformIO core + packages was successfully reinstalled. Does the above mentioned folder exist now, along with bin/avr-g++.exe in it?

no the .exe is not there. Can I just download it and place in the folder?

folder contents below:

image

No you’re looking at avr/bin there, but there should be bin/.

thanks for your help with it Max. Any ideas where I should go from here?