Arduino IDE multiple libraries

Hey, Idk if I'm just dumb, but I did not find any information on this issue anywhere.

I'm trying to program an ESP8266. Everything works, except sometimes, the sketch uses the right library (for the ESP) and sometimes it uses the built in AVR library which of course doesn't work. I have no idea who thought it was a good idea to name the esp library header exactly the same (just SoftwareSerial.h) but yeah. The Idea says it found multiple libraries, uses the wrong one and says that of course the syntax is wrong, cause they don't work the same. Is there any way I can define in the code or ide or whatever which library it should use? Of course i could just delete the AVR library, but as I'm also working equally as often with avr boards, that would just be a pain in the ... here is the console code:

"
serial.begin(9600, SWSERIAL_8N1, 0, 2);
^~~~~~~~~~~~
SERIAL_8N1
Mehrere Bibliotheken wurden für "SoftwareSerial.h" gefunden
Benutzt: C:\Users\felix\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SoftwareSerial
Nicht benutzt: D:\Documents\Arduino\libraries\EspSoftwareSerial
exit status 1
no matching function for call to 'SoftwareSerial::SoftwareSerial()'
"
yes, I'm german, it basicly says:
"
multiple libraries for "SoftwareSerial.h" found
use: C\FelixAppdata...theAVRone
not used: D\documents\ard\libs\EspSoftwareSerial(Theright one it should use!)
"

Thanks for your time :slight_smile:

I'm using a portable install for my ESP stuff (just started ESP). Maybe a solution for you.

If there is a conflict like you have, I will happily throw away the AVR version from that portable install.

The reason that the libraries are named the same us that you can write code that compiles on multiple platforms.

that sounds actually like more than I asked for. If I understand correctly, from what I just googled, I could also have a few portable IDEs for ArduAvr, ESP8266, ESP32, etc chilling in my cloud so I could also switch seamlessly from working on my pc to working on my laptop?

any quick tips/problems you encountered while doing so I should watch out for? :wink:

you could add a File

EspSoftwareSerial.h
containing

#include <SoftwareSerial.h>

in the src folder of the EspSoftwareSerial lib (the same folder were SoftwareSerial.h and SoftwareSerial.cpp already are)

and include that .h in your user sketch

#include <EspSoftwareSerial.h>

gives me a nice:
Alternatives for EspSoftwareSerial.h: [EspSoftwareSerial@6.12.6]
ResolveLibrary(EspSoftwareSerial.h)
-> candidates: [EspSoftwareSerial@6.12.6]

No idea, try it; not sure if you can run stuff in the cloud. My portable install is local. But you can have multiple portable installs that will not interfere with each other.

There used to be issues with source files stored in the cloud; no idea if they have been solved.

Which board do you have selected from the Arduino IDE's Tools > Board menu? The libraries under C:\Users\felix\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries should only be used when you have one of the AVR boards selected. If you are directly programming an ESP8266 board, then those libraries should be completely inaccessible, and in fact the ESP8266 platform bundled SoftwareSerial library should then become accessible.

you have asked Felix, but it seems I see the same with IDE 1.8.13: I can either try Generic ESP8266 or the NodeMCU V9 and if I just include the SoftSerial.h it get resolved on the SoftSerial.h

"C:\Users\werner\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/sdk/include" "-IC:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/sdk/lwip2/include" "-IC:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\Users\werner\AppData\Local\Temp\arduino_build_32560/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10813 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD="ESP8266_NODEMCU"" -DLED_BUILTIN=2 -DFLASHMODE_DIO -DESP8266 "-IC:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266" "-IC:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\variants\nodemcu" "C:\Users\werner\AppData\Local\Temp\arduino_build_32560\sketch\sketch_may29a.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SoftwareSerial.h: [EspSoftwareSerial@6.12.6 SoftwareSerial@6.8.5]
ResolveLibrary(SoftwareSerial.h)

Neither of these is the AVR version of the SoftwareSerial library. The AVR library is at version 1.0:

The ESP8266 boards platform uses the plerup/espsoftwareserial library as a Git submodule for its platform bundled SoftwareSerial library:
https://github.com/esp8266/Arduino/tree/master/libraries
I can see that is the EspSoftwareSerial@6.12.6 shown in your list:
https://github.com/plerup/espsoftwareserial/blob/c7c48b7583c985825ecc0d9e2a54468e782bff03/library.properties#L2
As for this SoftwareSerial@6.8.5 library, I'd guess it's a library you have installed in your sketchbook independently of the ESP8266 boards platform, similar to @felixbaum310's D:\Documents\Arduino\libraries\EspSoftwareSerial

I can find:

name=SoftwareSerial
version=1.0

in

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial

And
the only additional Serial Lib in my library folder (C:\Daten\myrepository\Arduino) - was installed via the lib manager an hour ago to reproduce Felix' installation

name=EspSoftwareSerial
version=6.12.6

it's in
C:\Daten\myrepository\Arduino\libraries\EspSoftwareSerial

The

name=EspSoftwareSerial
version=6.8.5

(seems to) comes from my ESP folder:

C:\Users\werner\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial

If I compile for an Uno, I get 1.0

"C:\Users\werner\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\werner\AppData\Local\Temp\arduino_build_32560\sketch\sketch_may29a.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SoftwareSerial.h: [SoftwareSerial@1.0 EspSoftwareSerial@6.12.6]
ResolveLibrary(SoftwareSerial.h)

but don't care about my installation, let's wait for Felix...

Ah, OK. The version is different because you have an older version of the ESP8266 platform, which has the submodule pointing to an older release of the library:

1 Like

I selected the ESP8266 NodeMCU 1.0

yeah that works, but then I get issues when I want to use the AVR board sometimes, I'll go with the portable version solution, thanks!

thanks for your effort, I'm actually really happy with the portable version solution, cause it allows me to have my workspace for different boards with the needed libs in my cloud and therefor on any pc, which was another pain in the butt I had. (Esp when cramping as much as possible on a nano, then it would compile on one pc but not on the other)