undefined reference in "RTClib.h"

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
normlane
 
Posts: 128
Joined: Thu Apr 01, 2010 5:39 pm

undefined reference in "RTClib.h"

Post by normlane »

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.)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: undefined reference in "RTClib.h"

Post by adafruit_support_rick »

Are you getting an error? That library has been around for ages.

User avatar
normlane
 
Posts: 128
Joined: Thu Apr 01, 2010 5:39 pm

Re: undefined reference in "RTClib.h"

Post by normlane »

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.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: undefined reference in "RTClib.h"

Post by adafruit_support_rick »

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:

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;
}

McSummation
 
Posts: 12
Joined: Wed Feb 27, 2013 5:29 pm

Re: undefined reference in "RTClib.h"

Post by McSummation »

I just ran into the same issue. Could you fix the cpp file and reupload it?

User avatar
normlane
 
Posts: 128
Joined: Thu Apr 01, 2010 5:39 pm

Re: undefined reference in "RTClib.h"

Post by normlane »

Take care. Some of the DateTime init code expects unixtime not secondstime.Check the code in the library.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: undefined reference in "RTClib.h"

Post by adafruit_support_rick »

OK . The library is updated on github. Grab a fresh copy and give it a try

McSummation
 
Posts: 12
Joined: Wed Feb 27, 2013 5:29 pm

Re: undefined reference in "RTClib.h"

Post by McSummation »

I grabbed the update, changed unixtime to secondstime in my sketch and it works properly. Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”