undefined reference in "RTClib.h"
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- normlane
- Posts: 128
- Joined: Thu Apr 01, 2010 5:39 pm
undefined reference in "RTClib.h"
It looks like "secondstime" is declared in the header file but not defined in cpp. Shouldn't that be "secondsTime" anyway? (and unixtime as unixTime for that matter.)
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: undefined reference in "RTClib.h"
Are you getting an error? That library has been around for ages.
- normlane
- Posts: 128
- Joined: Thu Apr 01, 2010 5:39 pm
Re: undefined reference in "RTClib.h"
Yeah, here's the error...
saveTime.cpp.o: In function `setup':
C:\arduino/saveTime.ino:36: undefined reference to `DateTime::secondstime() const'
My code...
Serial << newTime.unixtime() << endl;
Serial << newTime.secondstime() << endl;
The unixtime() call works.
Perhaps no one has had a reason to use that function before? I want to initialize a DateTime object with a 32 bit number instead of text. Now that I look more closely I think I should be using unixtime() anyway. For some reason the code seems to expect that but when you initialize with text it chokes on valid unix times with a year less than 2000 and adds an extra 100 years. 1999 will turn into 2099. If you get under the hood this library is a little odd.
Anyway, the missing code for secondstime() is a bug but it's apparently not very critical if no one else has tried to use it.
saveTime.cpp.o: In function `setup':
C:\arduino/saveTime.ino:36: undefined reference to `DateTime::secondstime() const'
My code...
Serial << newTime.unixtime() << endl;
Serial << newTime.secondstime() << endl;
The unixtime() call works.
Perhaps no one has had a reason to use that function before? I want to initialize a DateTime object with a 32 bit number instead of text. Now that I look more closely I think I should be using unixtime() anyway. For some reason the code seems to expect that but when you initialize with text it chokes on valid unix times with a year less than 2000 and adds an extra 100 years. 1999 will turn into 2099. If you get under the hood this library is a little odd.
Anyway, the missing code for secondstime() is a bug but it's apparently not very critical if no one else has tried to use it.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: undefined reference in "RTClib.h"
That is bizarre. I guess you're the first person to try to use that function.
The function itself is pretty simple - it's just unixtime without the constant add:
The function itself is pretty simple - it's just unixtime without the constant add:
Code: Select all
uint32_t DateTime::secondstime(void) const {
uint32_t t;
uint16_t days = date2days(yOff, m, d);
t = time2long(days, hh, mm, ss);
return t;
}
-
- Posts: 12
- Joined: Wed Feb 27, 2013 5:29 pm
Re: undefined reference in "RTClib.h"
I just ran into the same issue. Could you fix the cpp file and reupload it?
- normlane
- Posts: 128
- Joined: Thu Apr 01, 2010 5:39 pm
Re: undefined reference in "RTClib.h"
Take care. Some of the DateTime init code expects unixtime not secondstime.Check the code in the library.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: undefined reference in "RTClib.h"
OK . The library is updated on github. Grab a fresh copy and give it a try
-
- Posts: 12
- Joined: Wed Feb 27, 2013 5:29 pm
Re: undefined reference in "RTClib.h"
I grabbed the update, changed unixtime to secondstime in my sketch and it works properly. Thanks.
Please be positive and constructive with your questions and comments.