electric-sheep-co / arduino-redis

A Redis client library for Arduino.
http://arduino-redis.com
MIT License
54 stars 19 forks source link

Hello world library throws error with Vector dependency #59

Closed Marian0 closed 1 year ago

Marian0 commented 1 year ago

Hey guys!

I was looking for some pubsub libraries for Arduino and your looks really promising ! Thanks for sharing it.

While trying to use it on a personal project, I got the following error while compiling once I include the library:

In file included from /Users/***/Sites/***/Bicho/bicho/bicho.ino:3:0:
/Users/***/Documents/Arduino/libraries/Redis_for_Arduino/Redis.h:32:10: fatal error: vector: No such file or directory
 #include <vector>
          ^~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

I'm using Arduino IDE Version 2.0.3 on OSX M1.

Any ideas how to fix this so I can continue trying to use it ?

Thank you!

holla2040 commented 1 year ago

did you install lib version 2.5?

oddsix commented 1 year ago

I'm having the same problem with . I've installed 2.5.0 and it still complains.

rpj commented 1 year ago

@oddsix are you also trying to build this on an Apple M1- or M2-based machine?

oddsix commented 1 year ago

@rpj no, It's on a Linux desktop, Mint 20.02, Intel chip i9-13900k.

rpj commented 1 year ago

@oddsix Thanks a lot for the quick update!

Very curious, as I'm unable to reproduce on a Linux desktop running Ubuntu 20 and IDE 2.0.3, nor on a Windows 10 desktop running IDE 1.8 or 2.0.3. I do not have an ARM-based Mac myself, an although I do own an Intel Mac it is currently non-operational so I cannot try to repro there right now.

Would you mind sharing the exact code you're trying to build so I can try to reproduce explicitly?

Also, the verbose build output you're seeing might be enlightening too if you could. You can enable this in Preferences by checking "Show verbose output during [x] compile".

@Marian0, I'd ask the same of you as well if you could?

Thank you!!

oddsix commented 1 year ago

@rpj I will do so tonight. I forgot to add that I'm using a fresh download of the nightly build of the Arduino IDE.

rpj commented 1 year ago

@oddsix Awesome thank you! Very good to know also, yeah that might have something to do with it although if @Marian0 is using the stock 2.0.3 build and also hitting this failure... Either way, if you have the spare cycles to try the stock 2.0.3 build yourself on Mint that might be a great data point too. Thanks again!

holla2040 commented 1 year ago

Ubuntu 22.04 Deleted ~/Arduino/libraries/Redis_for_Arduino/ Running ./arduino-ide_2.0.3_Linux_64bit.AppImage Installed Redis for Arduino@2.5.0 Selected "DOIT ESP32 DEVKIT V1" Opened Example/Redis for Arduino/Simple Compiled without errors

Sketch uses 731089 bytes (55%) of program storage space. Maximum is 1310720 bytes. Global variables use 43244 bytes (13%) of dynamic memory, leaving 284436 bytes for local variables. Maximum is 327680 bytes.

oddsix commented 1 year ago

@rpj even a simple sketch like this shows the build error.

#include <Redis.h>
#include <Wifi.h>

#define WIFI_SSID "somessid"
#define WIFI_PASSWORD "somepassword"

void setup() {
  // put your setup code here, to run once:
  Serial.println("In setup")''
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("I'm looping");
}
Using board 'mega' from platform in folder: /root/.arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /root/.arduino15/packages/arduino/hardware/avr/1.8.6
In file included from /tmp/.arduinoIDE-unsaved202319-7840-yf914p.7pz2c/sketch_feb9b/sketch_feb9b.ino:1:0:
/home/erobbins/Projects/Arduino/libraries/Redis_for_Arduino/Redis.h:32:10: fatal error: vector: No such file or directory
 #include <vector>
          ^~~~~~~~
compilation terminated.
Detecting libr…tions -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/root/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/root/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega /tmp/arduino-sketch-98281CC9E4096CD32F0FD6F0F08CC65C/sketch/sketch_feb9b.ino.cpp -o /dev/null
Alternatives for Redis.h: [Redis for Arduino@2.5.0]
…Compilation error: exit status 1
rpj commented 1 year ago

Ah ha! I figured it out, and it was a single word - 'mega' - in your output @oddsix, plus noting that @holla2040 used an ESP32 board target in his, that turned the light on for me. I can now reproduce your failure on Ubuntu 20 by targetting the "Arduino Mega or Mega 2560" board type (or any number of other non-ESP board types):

Using board 'mega' from platform in folder: /home/ryan/.arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /home/ryan/.arduino15/packages/arduino/hardware/avr/1.8.6
In file included from /tmp/.arduinoIDE-unsaved202319-1190708-117nk7.oyi2z/SubscribeNonBlocking/SubscribeNonBlocking.ino:1:0:
/home/ryan/Arduino/libraries/Redis_for_Arduino/Redis.h:32:10: fatal error: vector: No such file or directory
 #include <vector>
          ^~~~~~~~
compilation terminated.
Detecting libraries used...

Accordingly, the resolution is that you'll need to build against an ESP board type because the compilation toolchain for those boards is different than that for standard Arudinos. This of course means you'll need actual boards of one of those types.

I have no idea why the vector header is (now?) missing from the standard Arduino toolchain now, but for better or worse this library has never officially supported boards beyond the ESP series so it's not technically a breakage. I've always wanted to build that support (and would heartily welcome any PRs that did! 😉) but haven't yet had the time.

Here are the instructions on adding the appropriate extra board manager URLs to your Arduino IDE for the given SOCs:

My apologies if this ends up resulting in this library not fitting your needs! I truly appreciate all the help in figuring this one out, and will do my best to prioritize support for other SOCs in the near future.

oddsix commented 1 year ago

@rpj Ah thanks. Frankly I didn't spend a lot of time on this. My use case is so simple, need to fire an event when my oil burner turns on, that it was just as easy to do it directly across the wire. I haven't touched any of the Arduino stuff in years, but I'm pretty sure I have some other boards kicking around that meet the requirements to build. When I'm done with my little project, I might come back to this and see what I can do. Thanks again.