Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: How to override built-in libraries reliably

  1. #1
    Senior Member
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    157

    How to override built-in libraries reliably

    Hi,
    I'm trying to use some newer and modified versions of libraries and override the ones built into Arduino and Teensiduino. I've been adding them to my ~/Documents/Arduino/libraries directory and it mostly works. But I can't figure out why one library does not.


    As you can see below the libraries in my home directory are used and the ones inside the Arduino app are not, with the exception of the Adafruit_GFX library. Does anybody have any idea how Arduino chooses which library to use? Are the Teensy provided ones special in some way?

    Here's the result from building with Arduino 1.5.7:
    Code:
     
    Multiple libraries were found for "ILI9341_t3.h"
     Used: /Users/dean/Documents/Arduino/libraries/ILI9341_t3
     Not used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3
    Multiple libraries were found for "Adafruit_GFX.h"
     Used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
     Not used: /Users/dean/Documents/Arduino/libraries/Adafruit-GFX-Library
    Multiple libraries were found for "FastLED.h"
     Used: /Users/dean/Documents/Arduino/libraries/FastLED
     Not used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/FastLED
    Multiple libraries were found for "Time.h"
     Used: /Users/dean/Documents/Arduino/libraries/Time
     Not used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/Time
    Multiple libraries were found for "Audio.h"
     Used: /Users/dean/Documents/Arduino/libraries/Audio
     Not used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/Audio

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,574
    This appears to be the only one where your override isn't working

    Multiple libraries were found for "Adafruit_GFX.h"
    Used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
    Not used: /Users/dean/Documents/Arduino/libraries/Adafruit-GFX-Library
    Notice the directory name exactly matches the library name in Teensy's folder, but yours isn't named the same.

    Try changing the folder name, to *exactly* the same name as the library.

  3. #3
    Senior Member
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    157
    That was it! Thanks again, Paul!

  4. #4
    Member
    Join Date
    Jul 2015
    Location
    Michigan, US
    Posts
    30
    Would you mind expanding that explanation a bit? I'm having a similar problem.
    Just upped to 1.25-beta2 and the latest teensyduino and I'm getting all kinds of issues. I'm not at my home machine, so I cant post the code or errors just yet, but I'm getting a couple of errors:
    redefinition of 'class Adafruit_GFX_Button'
    class Adafruit_GFX_Button {

    I'm mostly trying to decide how to select a version specifically if it has been tweaked without renaming every version of a file. Kind of wish I could REM out files in the computer so that they didn't get seen.

    Thanks
    Mark

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,332
    Quote Originally Posted by boroko View Post
    Would you mind expanding that explanation a bit? I'm having a similar problem.
    Just upped to 1.25-beta2 and the latest teensyduino and I'm getting all kinds of issues. I'm not at my home machine, so I cant post the code or errors just yet, but I'm getting a couple of errors:
    redefinition of 'class Adafruit_GFX_Button'
    class Adafruit_GFX_Button {

    I'm mostly trying to decide how to select a version specifically if it has been tweaked without renaming every version of a file. Kind of wish I could REM out files in the computer so that they didn't get seen.

    Thanks
    Mark
    The name of the library has to exactly the same:

    in the OP
    Code:
    Multiple libraries were found for "Adafruit_GFX.h"
     Used: /Applications/Arduino 1.6.5.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
     Not used: /Users/dean/Documents/Arduino/libraries/Adafruit-GFX-Library
    the user renamed his verion of "Adafruit_GFX" directory to "Adadfruit-GFX-Library", but Arduino wants the file "Adafruit_GFX.h" in a directory called "Adafruit_GFX".
    Arduino found both libraries but the first one, where the .h file coincided with the library (directory) name was in the default library tree. So Arduino choose the default one.

    PS: I'm not using Arduino but the way Arduino searches libraries seems clear from Paul's comment and the list of notification (not errors) and the single error of the OP

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,574
    Quote Originally Posted by boroko View Post
    but I'm getting a couple of errors:
    redefinition of 'class Adafruit_GFX_Button'
    class Adafruit_GFX_Button {
    You probably have an unrelated problem, where you're including both ILI9341_t3.h and Adafruit_GFX.h.

    Recent changes to ILI9341_t3.h brought in some of the newer stuff from Adafruit_GFX.h, so you must not include both.

  7. #7
    Member
    Join Date
    Jul 2015
    Location
    Michigan, US
    Posts
    30
    Thank you. That explains bunches. I'm trying to get caught up on this platform and there are a few bumps. Onward and upward...
    Bo

  8. #8
    I have similar issue.... Teensyduino does not recognise Adafruit library they sent mi yesterday. I renamed library as directed to Adafruit_ST7735 and placed it in the library folder C:\Users\Igor\Documents\Arduino\libraries and Teensyduino does not want to use it. There are both files neaded the CPP and H file in the folder... I had once a problem importing, but solved it. This time I have problems.... Here is the message from compiler (there is an old library I renamed it to Adafruit_ST77351):
    Code:
    Multiple libraries were found for "Adafruit_ST7735.h"
     Used: C:\Program Files\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735     
     Not used: C:\Users\Igor\Documents\Arduino\libraries\Adafruit_ST77351
     Not used: C:\Users\Igor\Documents\Arduino\libraries\Teensy3_ST7735
     Not used: C:\Users\Igor\Documents\Arduino\libraries\Adafruit_ST7735
    Last edited by igor p; 09-07-2015 at 09:27 PM.

  9. #9
    Junior Member
    Join Date
    Nov 2015
    Posts
    17
    I know this is an older thread, but this is still an issue for me running Arduino IDE 1.6.11 and the beta of Teensyduino 1.30-beta3.

    The SSD1306 library from Adafruit and the GFX library keep defaulting to the ones in my library folder contained in the sketchbook folder. As you can see the SPI and Wire libraries are pulling from the hardware/teensy folder, but the others are not.

    I have made sure that the folder names are identical. I am not getting any compilation errors, but I am trying to understand why this happens...

    Code:
    Multiple libraries were found for "Adafruit_GFX.h"
     Used: D:\Docs\Google Drive\Arduino_New\libraries\Adafruit_GFX
     Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX
    Multiple libraries were found for "Adafruit_SSD1306.h"
     Used: D:\Docs\Google Drive\Arduino_New\libraries\Adafruit_SSD1306
     Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_SSD1306
    Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI 
    Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire 
    Using library Adafruit_GFX at version 1.1.5 in folder: D:\Docs\Google Drive\Arduino_New\libraries\Adafruit_GFX 
    Using library Adafruit_SSD1306 at version 1.1.0 in folder: D:\Docs\Google Drive\Arduino_New\libraries\Adafruit_SSD1306

  10. #10
    I have the same problem with:
    - the SD library
    - Adafruit_SSD1306 library

    And of course a lot of library error messages (the most from Adafruit) that use Wire1 - not defined in teensy 3.2.

    It seems impossible to use any standard Arduino library anymore on the new Teensy.

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,700
    spiff72 - anything in your "library folder contained in the sketchbook folder" will be used before others. On my system I have folders for sketchbook\libraries and sketchbook\NOT_libraries in some fashion. When I want something moved for any reason I move it to the NOT_ folder.

    The IDE needs to restart to scan for library changes - at least additions.

    Adriano - you must be doing something wrong - or have found a bug nobody noticed. Check and, following the "page top" 'Forum Rule', post the details of any error you end up with. Generally standard libraries are included in TeensyDuino when they have the need for mods to work with the different processor architecture of Teensy's ARM chip. There are some alternative libraries that better utilize the speed and features of Teensy processor. For instance to use wire1 - look into #include <i2c_t3.h>.

    In fact I have a sketch open that runs on the new T_3.6 for the SSD_1306 with these header includes - all included with TeensyDuino. That library works on 'wire' - to use 'wire1' the AdaFruit source needs to be modified - and I have done that and tested it to work.

    Code:
    #include <SPI.h>
    //#include <Wire.h>
    #include <i2c_t3.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

  12. #12
    Junior Member
    Join Date
    Nov 2015
    Posts
    17
    Thanks defragster...

    That is helpful. I had already created a folder called "libraries_moved" and shifted a few libraries over to that folder, I just wanted to make sure that there wasn't a "better way".

    This actually prompts another question though. I was playing around with the RTC on the Teensy last night and found that I was having issues with the Time.h include. I have a Time folder in my teensy hardware library, as well as one that was in my sketchbook library folder (I can't figure out if these are different).

    Should teensy always use TimeLib.h instead?

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,700
    That came to me as an easy way to keep work in progress around - not seen any 'built in' other way.
    Yes, my working sample looks like this:
    Code:
    //#include <Time.h>
    #include <TimeLib.h>
    In general - unless you are customizing/importing a library - Teensy or one from outside - it shouldn't be in the library folder unless you want it there.

  14. #14
    Junior Member
    Join Date
    Nov 2015
    Posts
    17
    Thanks again! Sorry for all the questions today!

    I have a teensy and other uno-compatible boards, and my other RTC breakout is a DS3231, so I use a different library for the DS3231/Uno combination (RTCLib.h).

    I figured out that the two Time libraries are slightly different. The Time.cpp file for one of them uses the #include Time.h line while the other uses #include TimeLib.h (teensy version).

    The other difference is in the TimeLib.h file, where the one of them (teensy version) has the following difference:

    Code:
    non-teensy:
    #define SECS_PER_MIN  (60UL)
    #define SECS_PER_HOUR (3600UL)
    #define SECS_PER_DAY  (SECS_PER_HOUR * 24UL)
    #define DAYS_PER_WEEK (7UL)
    #define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK)
    #define SECS_PER_YEAR (SECS_PER_WEEK * 52UL)
    #define SECS_YR_2000  (946684800UL) // the time at the start of y2k
    
    
    teensy:
    #define SECS_PER_MIN  ((time_t)(60UL))
    #define SECS_PER_HOUR ((time_t)(3600UL))
    #define SECS_PER_DAY  ((time_t)(SECS_PER_HOUR * 24UL))
    #define DAYS_PER_WEEK ((time_t)(7UL))
    #define SECS_PER_WEEK ((time_t)(SECS_PER_DAY * DAYS_PER_WEEK))
    #define SECS_PER_YEAR ((time_t)(SECS_PER_WEEK * 52UL))
    #define SECS_YR_2000  ((time_t)(946684800UL)) // the time at the start of y2k
    Does it make sense to just leave the time library that is in the library-moved folder where it is since it isn't needed (I am thinking it is an older version of the Teensy version)? Probably just delete the folder altogether?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •