Arduino uno r4 wifi wire library error

Hi!
I try vertify a simple code.
It has a Wire.h, but i get error all the time:
Documents\Arduino\libraries\Wire\utility\twi.c:23:10: fatal error: avr/io.h: No such file or directory
#include <avr/io.h>
^~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1

Can you help me how to get the wire library to work with uno r4 wifi RA4M1 MCU?

Why do you think you need that line?

EDIT:
Never mind, I now see it's in twi.c. Go with @ptillisch's reply.

Use Wire.h

Hi @72zdhwo."Wire" is a "platform bundled library". This type of library is distributed as part of an Arduino boards platform (AKA "core"). This means that when you install or update a boards platform via the Arduino IDE "Boards Manager", you also install or update the "platform bundled libraries" of that boards platform. This is different from the standalone libraries we usually install and update via the Arduino IDE "Library Manager".

The "platform bundled libraries" of a boards platform are only accessible when compiling for a board of that platform. It is common for multiple boards platforms to each bundle their own variant of a given fundamental library. Typically this is done when the implementation of a library is very architecture-specific, meaning it is not feasible to make a single universal library that can be used with any Arduino board. Because each of the variants of the library use a standardized API, the same sketch code using the library can be used on boards of different architectures. The user is often not even aware that a different library variant is being used from one board to the next.

The error you encountered is caused by you having, for some unknown reason, made a universal installation of a "Wire" library for a different architecture than that of the UNO R4 WiFi board.

Making a manual installation of a library like "Wire" to the sketchbook folder should only be done by advanced users who have a very good reason for doing so. If you don't have a specific reason for having dumped this library into your sketchbook then the best solution will be to simply delete the folder at the path shown in the error:

(I see you redacted part of the path from the output you shared, but if you look at the full error message shown in the "Output" panel of Arduino IDE when you attempt to compile the sketch, you will see the full path).


:warning: Please be careful when deleting things from your computer. When in doubt, back up!


Deleting that installation of the "Wire" library will allow the Arduino build system to use the platform bundled installation of the "Wire" library that was written for the UNO R4 WiFi board.

In case you really do need the "Wire" library installation in the sketchbook folder, let me know and I'll provide instructions you can follow for a more complex approach to causing the library to not be used when compiling for the UNO R4 WiFi.

The Wire libary use this.
C:\Users\Documents\Arduino\libraries\Wire\utility\twi.c

It is more accurate to say that the variant of the Wire library that was written for use with microcontrollers of the AVR architecture "uses" that.

If you looked at the source code of the Wire library for the UNO R4 WiFi, you would find something completely different.

Thank you! Could you help me download the correct library?

You don't need to download it. It's already installed in C:\Users\yourUsername\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.4.1\libraries.

Do not touch the above, leave it there but remove the Wire library that you have in Documents\Arduino\libraries.