ReadTest example in DS1307 library doesn't compile

Fenichel

Well-known member
With no modification, the example doesn't compile. It begins
Code:
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
and that's enough to make the compiler complain. The compiler says
Code:
. . . arduino-1.8.8\hardware\teensy\avr\libraries\DS1307RTC\DS1307RTC.cpp:217:11: error: redefinition of 'DS1307RTC RTC'
DS1307RTC RTC = DS1307RTC(); // create an instance for the user
                  ^
In file included from ...arduino-1.8.8\hardware\teensy\avr\libraries\DS1307RTC\DS1307RTC.cpp:32:0:
... arduino-1.8.8\hardware\teensy\avr\libraries\DS1307RTC\DS1307RTC.h:37:11: note: DS1307RTC RTC previously declared here

Not surprisingly, the same thing happens with the SetTime example.
 
Last edited:
This may be a board or version specific problem ... can you add details ...

What Teensy is selected for the Board? Which IDE and TeensyDuino version?
 
I tried just now, but could not reproduce the problem. I tried for every Teensy model. All compile without error.

Here's a screenshot of the compile for Teensy 4.0.

sc.png
 
Given Paul's post above - it might be resolved with an update to the latest TeensyDuino. 1.48 has been released and 1.49 is in Beta and likely to be released in the next day - with no changes so far from the current 1.49 beta #5.
 
Normally I would just say to use the latest version, which I already confirmed works fine.

But this time, I started wondering if this really was broken back in 1.46-beta10, because these are all very mature libs that haven't changed much in recent years. So I unpacked a fresh copy of Arduino 1.8.8 and installed Teensyduino 1.46-beta10.

It compiles without any error when I test that old version. Here's a screenshot.

sc2.png
 
My best guess is you make have a local copy of 1 or more of these libs in your {Documents}/Arduino/libraries folder.

To check, click File > Preference and turn on verbose output while compiling. Then Verify again, and scroll up to see the info Arduino prints about the exact location where it's using each library.

Or you might have a corrupted copy of the software.
 
With more console output that could be seen where it shows what libraries are used from where.

IDE's "ctrl+comma" shows file/prefs and 'sketchbook' folder - that folder with be where 'libraries' are when local copies are stored.
 
My best guess is you make have a local copy of 1 or more of these libs in your {Documents}/Arduino/libraries folder.
No, there's nothing in that folder but the readme.txt file that tells me
Code:
For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries
To check, click File > Preference and turn on verbose output while compiling. Then Verify again, and scroll up to see the info Arduino prints about the exact location where it's using each library.
It says it took each of the Wire [version 1.0], Time [version 1.5], and DS1307RTC [version 1.4] libraries from ... arduino-1.8.8\hardware\teensy\avr\libraries
Or you might have a corrupted copy of the software.
Perhaps. What's the best way to get the latest stable versions of these?
 
solved

It says it took each of the Wire [version 1.0], Time [version 1.5], and DS1307RTC [version 1.4] libraries from ... arduino-1.8.8\hardware\teensy\avr\libraries

. . .What's the best way to get the latest stable versions of these?

I have answered my own question. I upgraded Teensyduino to 1.48, and that of course dragged in all the libraries. Now it compiles.

Thanks to Paul & defragster for prompt patient attention.
 
Back
Top