I have a project which includes OLED display, so I decided to use Adafruit_SSD1306 library. But I have problem with compiling code, which uses this library, in another .h file.

When I use this library in .ino file, everythings works, but in OLED.h file I get this error:

collect2.exe: error: ld returned 1 exit status
Multiple libraries found "DallasTemperature.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master
Multiple libraries found "OneWire.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\OneWire-master
Multiple libraries found "SPI.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SPI
Multiple libraries found "Wire.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\Wire
Multiple libraries found "Adafruit_GFX.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Adafruit_GFX_Library
Multiple libraries found "Adafruit_SSD1306.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Adafruit_SSD1306
Multiple libraries found "SrcWrapper.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper
Byly nalezené násobné knihovny "Adafruit_I2CDevice.h"
 Použitý: C:\Users\luky\Documents\Arduino\libraries\Adafruit_BusIO

The error is from this piece of code:

#include <SPI.h>
#include <Wire.h>

TwoWire Wire1(PB9, PB8); // Use STM32´s I2C2

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

STM32 Bluepill board is used.

  • Not sure if it solves the problem, but using #include after any code or variable declarations is not good coding practice. Put all #includes at the beginning. Jul 3 '20 at 8:38
  • Thanks thats good note.
    – LucasN
    Jul 3 '20 at 8:43
  • But its still dont works
    – LucasN
    Jul 3 '20 at 8:43
  • Sorry for that ... did you check if you installed multiple same-named libraries (maybe different versions?). Try to compile some sample sketches to see if something is wrong in your own code or within the libraries installation. Jul 3 '20 at 8:45
  • 1
    I also tried that. There is just the 1 library. Its very strange problem xD
    – LucasN
    Jul 3 '20 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.