Installing source package - failure to link

Error Information:

* installing *source* package 'mypkg' ...
** libs

*** arch - i386
C:/Users/WXC4/tools/R/Rtools/mingw_64/bin/gcc  -I"C:/Users/WXC4/tools/R/R-34~1.4/include" -DNDEBUG          -O3 -Wall  -std=gnu99 -mtune=generic -c grad_func.c -o grad_func.o
C:/Users/WXC4/tools/R/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o bibetaROC.dll tmp.def grad_func.o -LC:/Users/WXC4/tools/R/R-34~1.4/bin/i386 -lR
C:/Users/WXC4/tools/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Users/WXC4/tools/R/R-34~1.4/bin/i386/R.dll when searching for -lR
C:/Users/WXC4/tools/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Users/WXC4/tools/R/R-34~1.4/bin/i386/R.dll when searching for -lR
C:/Users/WXC4/tools/R/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lR
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'mypkg'
* removing 'C:/Users/WXC4/tools/R/My-R-Packages/mypkg'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/Users/WXC4/tools/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\WXC4\tools\R\My-R-Packages" "C:/Users/WXC4/Documents/Research/mypkg.tar.gz"' had status 1
Warning in install.packages :
  installation of package ‘C:/Users/WXC4/Documents/Research/mypkg.tar.gz’ had non-zero exit status

Description of issue -
Trying to build a package I developed years ago from source. My computer was recently refreshed and the R and RStudio were re-installed. Initially it cannot find gcc, then I used the trick here and it seems to solve the gcc problem. Then now it looks like having a linking problem.
Steps taken so far -

System Information:

  • RStudio Edition: Desktop
  • RStudio Version: Version 1.1.453
  • OS Version: Windows 10
  • R Version: R version 3.4.4 (2018-03-15)

From Troubleshooting Guide: Using RStudio

Hi, @roc! Welcome!

To help narrow down what’s going on here, does the same thing happen if you try to build your package from R, outside of RStudio?

These lines indicate that, for some reason, R is attempting to link to its 32-bit library even though the 64-bit compiler is being invoked. I'm not exactly sure why this is happening, though -- it could be something in your PATH, or something unique to your package's build process (it's hard to know without access to your package's sources)