Problem compiling packet caret

Error Information:

installing *source* package 'caret' ...
** package 'caret' successfully unpacked and MD5 sums checked
** using staged installation
** libs

*** arch - i386
"C:/Soft_x64/RTools/mingw32/bin/"gcc  -I"C:/PROGRA~1/R/R-41~1.1/include" -DNDEBUG          -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c caret.c -o caret.o
caret.c: In function 'knn3':
caret.c:23:14: warning: variable 'index' set but not used [-Wunused-but-set-variable]
     int   i, index, j, k, k1, kinit = *kin, kn, l = *lin, mm, npat, ntie,
caret.c: In function 'knn3reg':
caret.c:170:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (k = 0; k <= kn; k++)
caret.c:184:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
      nndist[kn] = 0.99 * DOUBLE_XMAX;
"zcaret.o" was unexpected at this time.
make: *** [caret.dll] Error 255
ERROR: compilation failed for package 'caret'
* removing 'C:/Users/guest2/Documents/R/win-library/4.1/caret'
Warning in install.packages :
  installation of package ‘caret’ had non-zero exit status

Description of issue -
I have a problem with compiling packet 'caret' in RStudio on Windows.
I have the last version of RSTUDIO (1.4.1717) and last version of R (4.1.1) and the last version of RTools( [rtools40v2-x86_64.exe]). Can someone help ME PLEASE. Since 48 hours i can't do that.

Steps taken so far -
I updated my Windows and i tried compile with 32 bit the same R version or 3.6.1.
It's not help me and still it does not working!

System Information:

  • RStudio Edition: (Desktop or Server)
  • RStudio Version:
  • OS Version:
    OS Name:: Microsoft Windows 10 Education, OS Version: 10.0.19042 N/A Build 19042
  • R Version:


  • RStudio diagnostics report:
  • Your sessionInfo():
  • RStudio crash report:
  • RStudio application log files:

From Troubleshooting Guide: Using RStudio