Not sure what to do?

I'm getting this message from the compiler and I'm not sure how to resolve it.

c:/users/john/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-gettimeofdayr.o): In function `_gettimeofday_r':

gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to `_gettimeofday'

Thanks.

it not's finding a matching function with that name or possibly with the argument types you're passing it

Post source code

Read "How To Use This Forum"

in particular, 7. If you are posting code or error messages, use "code" tags

This is what happens when you do not

if you have a module that is not working, do not say "A GPS" or "the fingerprint sensor". Show us a link to the particular sensor, and a link to the datasheet if available

Thanks for the feedback folks.

The source code is several thousand lines long, posting could be difficult. :slight_smile:

From my reading of the error text, it's not in my code but in a standard library as can be seen by the lack of a source file and line number. It appears to be in libc.a

GE, thanks for your vigilance and the advice on how to use the forum and the reason you posted, BUT, it's totally inappropriate to my situation.

Thanks.

The accepted and standard way to ask for help with code is to post the minimum code that demonstrates the error.

None of us is the least bit interested in looking through your "several thousand lines of code", especially when the problem is as trivial as getting the time of day.

Just by the way, where would the time of day be coming from, in your yet to be described Arduino?

Context is necessary to help.
Is that the first warning or error from the compiler ?

Would it be fair to ask if the specific time library has been installed ?

OzMaz:
From my reading of the error text, it's not in my code but in a standard library as can be seen by the lack of a source file and line number. It appears to be in libc.a

BUT, it's totally inappropriate to my situation.

need to see how the function is being called, with which arguments and how those arguments are defined (see gettimeofday())

ok, context.

Most of the code is not my own and I'll explain why.

I spotted this project on YouTube and it looked an interesting challenge.

Although the YouTube project uses an ST microcontroller I had trouble making that work, so I bought and Arduino Due, similar specs.1

The article gives a reference to the source code in GitHub.

I had some trouble with the include statements, so I opted to port blocks of code as the compiler needed them.

In the original code, the time is manually entered (seconds past 1/1/1970) with a cryptic note to make it smarter, so I did. I purchased a Duinotech GPS module and wrote some supporting code which works well.

The code uses the processors RTC to keep track of elapsed time, so I tried doing the same thing and used the RTCDue library. I seem to have succeeded, but have a secondary issue that the Arduino things there are multiple libraries of RTCDue, I'm trying sort things out. The compiler makes a choice of which library to use and after fixing a few things in the library I am now faced with what I think is a linker error as the error message does not mention and source code, just a library.

As I said, I'm not sure what to do, but I'll try and resolve the multiple library instance first and see what eventuates.

In desperation I installed the Arduino IDE on anther computer and tried compiling the source code and now have a different error in that it complains it cant find RTDue.h in some subfolder. I'll leave that and work on the original computer.

Hope this helps in some way.

I had some trouble with the include statements, so I opted to port blocks of code as the compiler needed them.

I recommend a different strategy, namely go through all the project code and edit it as required to make it into a complete, intact program that follows the Arduino guidelines, before offering it up for compilation.

That way you gain a clear overview of the code, before getting mired down by silly mistakes.

Hi,

I started from scratch and added a function at a time until the error appeared.

I then went back and took out what I had just added until the error disappeared and moved forward again.

I found a function whose appearance caused the error. The strangest thing is that the mere appearance of the routine definition (with one line of code, the rest commented out) causes the error. Just makes no sense!

Whilst searching on the internet I have found posts that state there a various versions of libc, some more complete than others, which may be the problem.

I'll keep looking.

This appears to be the missing bit.
https://chromium.googlesource.com/native_client/nacl-newlib/+/master/newlib/libc/reent/gettimeofdayr.c

The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU and that function is not included in the default install I think (Current version is 1.6.12)

could you take an approach like this where you provide your own function

struct timeval {
  long tv_sec;
  long tv_usec;
};

int gettimeofday( struct timeval *tv, void *tzvp __attribute__((unused)))
{
  const uint32_t offSetSinceEpoch_s =  1581897605UL; // poor approach would need to be right at run time...
  uint32_t mt = millis() ; // replace with your time call returning real ms

  tv->tv_sec = offSetSinceEpoch_s  + (mt / 1000);
  tv->tv_usec = tv->tv_sec * 1000000UL;
  return 0;
}

void setup()
{
  Serial.begin(115200);
  timeval t;
  gettimeofday(&t, NULL);
  Serial.println(t.tv_usec);
}

void loop() {}

Thanks for posting J-M-L.

I was thinking, halfway through the night as you do, when I decided I knew what was wrong.

The Arduino Due is indeed an Atmel SAM3X8E which has an internal RTC.

The problem is that the code I am trying to use/port is for an STM32F401.

I am using the internal RTC to simplify things. The RTCDue library provides this functionality. However in the ST environment MBED is used and of course it's a different call , they use time(NULL) to get the UNIX time. I need to use getYear(), getMonth(),... etc.

Since modifying the code I no longer get the linking error, I can move on.

The error messages I was getting in no way pointed me to a solution, well maybe a little, in the sense it was a get time issue. Tracking back to the offending line just took a bit of searching.

Anyway, thanks to all who posted.

Hi,

3,600 lines and 110K, glad I'm on this side of it. :slight_smile: