Photon RedBoard/TFT Adafruit 2.8'': multiple definition of

Hello dear community,

Error:
lib/Adafruit_GFX/Adafruit_GFX.cpp:420:0: multiple definition of “Adafruit_GFX::drawLine(short, short, short, short, unsigned short)”

Heres what I did: I want to setup my RedBoard with the Adafruit TFT. To test it, i followed this Tutorial (designed for Arduino IDE).

  1. I opened Particle IDE
  2. I created a new App.
  3. I included the two libraries mentioned in the tutorial. The references to the header and the comment implying it did so were added to my file.
  4. I copied the full example source code from github (Repo) and removed the two (previously automatically added) include statements.
  5. I tried veryfing the code and ended up with about 15 more error messages as above. They simply concerened different functions.

I checked the library files and there weren’t multiple implemenations of the same funcitons. Neither did I include the same header file multiple times. Am I doing something obviously wrong? Or are the libraries only cut out for Arduino platform?

Thanks in advance for any hints.

If you are using Web IDE it’s best to post a SHARE THIS REVISION link so we can have a look at an exact copy of your project (including library setup).
This makes pinpointing your issues much easier for us.

BTW, what system version are you targeting?

Im targeting firmware 0.7.0. Installed on the RedBoard is the 0.5.3.

Heres the share link to the revision. https://go.particle.io/shared_apps/5bf40aac85907f1eb6001794

The reason for your double definitions is that the Particle port of the Adafruit_ILI9341 library already has an internal reference to Adafruit_mfGFX (see here) hence you shoudn’t import Adafruit_GFX.
When you remove the library and the respective include statement from your project it should compile.

3 Likes

Perfect. Thank you for your quick replies and accurate questioning. Thumbs up!

Just to round things up, here’s the “detailed” fixing procedure:

  1. Remove the “Adafruit_GFX” library from the app
  2. Remove the include Adafruit_GFX statement from the code

For further understanding: Whenever a library is imported I should check it’s property file to prevent double references. Is this actually good practice?

If the library itself does not state that it depends on any other library then importing the library alone should suffice.
If it doesn’t state the fact but still would require the user to import another lib then this can be considered poor practice and should be addressed via a GitHub issue on the library repo.

Tutorials tend to get out of date and hence should not be taken without double checking whether or not things have changed since.
The primary source of information should be the tools the tutorial is based on.