Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

undefined reference in "RTClib.h"
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

undefined reference in "RTClib.h"

by normlane on Thu May 22, 2014 11:14 pm

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

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

Re: undefined reference in "RTClib.h"

by adafruit_support_rick on Fri May 23, 2014 12:09 pm

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

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: undefined reference in "RTClib.h"

by normlane on Sat May 24, 2014 2:32 pm

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.

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

Re: undefined reference in "RTClib.h"

by adafruit_support_rick on Sat May 24, 2014 6:06 pm

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 | TOGGLE FULL SIZE
uint32_t DateTime::secondstime(void) const {
  uint32_t t;
  uint16_t days = date2days(yOff, m, d);
  t = time2long(days, hh, mm, ss);
  return t;
}

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: undefined reference in "RTClib.h"

by McSummation on Mon Jun 30, 2014 7:21 pm

I just ran into the same issue. Could you fix the cpp file and reupload it?
McSummation
 
Posts: 12
Joined: Wed Feb 27, 2013 5:29 pm

Re: undefined reference in "RTClib.h"

by normlane on Tue Jul 01, 2014 12:05 am

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

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

Re: undefined reference in "RTClib.h"

by adafruit_support_rick on Tue Jul 01, 2014 10:38 am

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

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: undefined reference in "RTClib.h"

by McSummation on Tue Jul 01, 2014 3:20 pm

I grabbed the update, changed unixtime to secondstime in my sketch and it works properly. Thanks.
McSummation
 
Posts: 12
Joined: Wed Feb 27, 2013 5:29 pm

Please be positive and constructive with your questions and comments.