Error in library using Wokwi

Hello everybody.
I don't know if I posted in the right place and I apologize in advance if I'm wrong.

I use and really enjoy using the wokwi simulator.
" https://wokwi.com "
It has always worked correctly.
I'm not a "club" user, but a (free) user.

As I did not find on the site a place to report occurrences,
I'm using the Arduino forum for this purpose.

Today when testing a sketch I had difficulty with a library.

I summarized the sketch as much as possible:

#include <DS1307RTC.h>
void setup() {
}

void loop() {
  // put your main code here, to run repeatedly:
}

In the "Library Manager" tab, include the DS1307RTC.h library.
When running I got the error message:

In file included from sketch.ino:2:0:
/libraries/DS1307RTC/DS1307RTC.h:9:10: fatal error: TimeLib.h: No such file or directory
 #include <TimeLib.h>
          ^~~~~~~~~~~~
terminated compilation.

Error during build: exit status 1

I tried to include this library, but it didn't allow it because it doesn't exist in the list of libraries for "free" users.

I ask, what is the point of making a free library available to the user but who needs another library that is not free?

Thank you in advance

edit: never mind, didn't read carefully...

You don't need to be a club member to have an account, still free. Maybe you have an account.

I had no trouble on my GF's machine as an anonymous user:

Go to the library manager tab, hit the big purple plus button and start typing the name of a library you want to use.

 DS1307

was enough to show up the DS1307RTC library.

HTH

a7

Does the WokWi simulator pretend that the DS1307 can keep accurate time, or does it model realistically poor performance?

LOL! I suspect it does not bother to be crappy, and I bet no one runs it long enough in simulation for it to make a difference.

The wokwi is realistic about some things, like switch bounce.

I think the RTC implementations also suffer from coming up with the current date and time automatically...

Some things like playing with the backup battery or what exactly happens over a power cycle (or over many hours or months, for that matter) will have to be done IRL.

a7

It does exist. Even though it is common, not all library names match the header filename. In this case, the library is named "Time", not "TimeLib". So search the Library Manager for "Time", add it to your project, and you'll be set.

2 Likes

Tks @ptillisch,
I used the Time library and it worked.

Hi @alto777,
I think I was not clear in my description.
The library " DS1307RTC " I was able to select,
but when running the sketch I got the error message asking for the library " TimeLib ".
This one I couldn't find.

1 Like

No, I was just not reading carefully and was more concerned about the idea that wokwi has any class barriers.

a7

You are welcome. I'm glad it is working now.

Since the name is defined in the library's metadata, the library author can choose any arbitrary name they like (though it is encouraged as best practices to make the name and primary header filename match).

In this specific case, there actually is an interesting technical explanation for the mismatch: The primary header filename of this popular library was Time.h for many years. Eventually a problem arose with this name. The toolchain contains a header file named time.h which has priority over the Arduino libraries for #include directive resolution. On the case sensitive file system of Linux, this was no problem because Time.h and time.h are two different filenames. However, on the case insensitive file systems of Windows and macOS, this is a problem because the two are equivalent. So the #include directives in code with a dependency on the "Time" library would instead end up resolving to using this incompatible time.h header instead:

The problem was commonly associated with the Arduino IDE 1.6.6 release because it included an updated version of the bundled "Arduino AVR Boards" platform which contained the problematic time.h file, but actually the problem already affected other boards platforms with this file in their toolchain, and also affected users of previous IDE versions who updated their "Arduino AVR Boards" platform via Boards Manager, so it wasn't so much coupled to the IDE version.

The workaround that was employed by the library maintainer Paul Stoffregen was to add a header file with a unique name TimeLib.h and recommend that all #include directives be changed from Time.h to TimeLib.h:

The use of TimeLib.h is now enforced by the complete removal of Time.h after it was judged that sufficient time had passed to allow the dependent code to transition to using TimeLib.h:

1 Like

Tks @ptillisch .
Thank you very much for the solution and the explanation of the reasons.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.