IshidaMotohiro / RMeCab

Interface to MeCab
29 stars 10 forks source link

Installation of RMeCab in RStudio with rtools40 failed #11

Closed CLRafaelR closed 3 years ago

CLRafaelR commented 3 years ago

I'm trying to install the latest RMecab (1.07) from GitHub to a Windows 10 machine with R 4.0.2 using rtools40. However, the installation fails with the following error message. Would you mind telling me what I am missing?

> remotes::install_github("IshidaMotohiro/RMeCab")
Downloading GitHub repo IshidaMotohiro/RMeCab@HEAD
√  checking for file 'C:\Users\users\AppData\Local\Temp\RtmpyCnzNK\remotesa3c55da2e19\IshidaMotohiro-RMeCab-9b26672/DESCRIPTION' (368ms)
-  preparing 'RMeCab': (456ms)
√  checking DESCRIPTION meta-information ...
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts (444ms)
-  checking for empty or unneeded directories
-  building 'RMeCab_1.07.tar.gz'

Installing package into ‘C:/Users/users/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package 'RMeCab' ...
** using staged installation
** libs
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c Ngram.cpp -o Ngram.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from Ngram.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from Ngram.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c NgramDF.cpp -o NgramDF.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from NgramDF.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from NgramDF.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c NgramDF2.cpp -o NgramDF2.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from NgramDF2.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from NgramDF2.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCab.cpp -o RMeCab.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCab.cpp:23:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCab.cpp:23:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCabC.cpp -o RMeCabC.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCabC.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCabC.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCabDoc.cpp -o RMeCabDoc.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCabDoc.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCabDoc.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCabFreq.cpp -o RMeCabFreq.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCabFreq.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCabFreq.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCabMx.cpp -o RMeCabMx.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCabMx.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCabMx.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RMeCabText.cpp -o RMeCabText.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from RMeCabText.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from RMeCabText.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c collocate.cpp -o collocate.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from collocate.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from collocate.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

collocate.cpp: In function 'SEXPREC* collocate(SEXP, SEXP, SEXP, SEXP)':
collocate.cpp:202:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
     while( (z + y) <= vec1.size()){// node蠕後・隱槭・蜃ヲ逅・            ~~~~~~~~^~~~~~~~~~~~~~
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c docDF.cpp -o docDF.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from docDF.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from docDF.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c docMatrix2.cpp -o docMatrix2.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from docMatrix2.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from docMatrix2.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c docMatrixDF.cpp -o docMatrixDF.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from docMatrixDF.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from docMatrixDF.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c docNgram2.cpp -o docNgram2.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from docNgram2.cpp:2:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from docNgram2.cpp:2:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c docNgramDF.cpp -o docNgramDF.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from docNgramDF.cpp:1:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from docNgramDF.cpp:1:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I.         -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c setMeCabMap.cpp -o setMeCabMap.o
In file included from C:/PROGRA~1/R/R-40~1.2/include/R.h:91,
                 from RMeCab.h:27,
                 from setMeCabMap.cpp:24:
C:/PROGRA~1/R/R-40~1.2/include/R_ext/RS.h:55: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}

In file included from C:/rtools40/mingw64/x86_64-w64-mingw32/include/windows.h:71,
                 from ./mecab.h:339,
                 from RMeCab.h:25,
                 from setMeCabMap.cpp:24:
C:/rtools40/mingw64/x86_64-w64-mingw32/include/wingdi.h:75: note: this is the location of the previous definition
 #define ERROR 0

C:/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o RMeCab.dll tmp.def Ngram.o NgramDF.o NgramDF2.o RMeCab.o RMeCabC.o RMeCabDoc.o RMeCabFreq.o RMeCabMx.o RMeCabText.o collocate.o docDF.o docMatrix2.o docMatrixDF.o docNgram2.o docNgramDF.o setMeCabMap.o -L../src-x64 -lmecab64 -LC:/PROGRA~1/R/R-40~1.2/bin/x64 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmecab64
collect2.exe: error: ld returned 1 exit status
installing to C:/Users/users/Documents/R/win-library/4.0/00LOCK-RMeCab/00new/RMeCab/libs/x64
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'RMeCab'
    finding HTML links ... done
    Ngram                                   html  
    NgramDF                                 html  
    NgramDF2                                html  
    RMeCabC                                 html  
    RMeCabDF                                html  
    RMeCabDoc                               html  
    RMeCabFreq                              html  
    RMeCabMx                                html  
    RMeCabText                              html  
    coOccurrence                            html  
    collScores                              html  
    collocate                               html  
    docDF                                   html  
    docMatrix                               html  
    docMatrix2                              html  
    docMatrixDF                             html  
    docNgram                                html  
    docNgram2                               html  
    docNgramDF                              html  
    print.docMatrix                         html  
    rmSign                                  html  
    weights                                 html  
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'RMeCab' in library.dynam(lib, package, package.lib):
 DLL 'RMeCab' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/users/Documents/R/win-library/4.0/RMeCab'
* restoring previous 'C:/Users/users/Documents/R/win-library/4.0/RMeCab'
Error: Failed to install 'RMeCab' from GitHub:
  (converted from warning) installation of package ‘C:/Users/users/AppData/Local/Temp/RtmpyCnzNK/filea3c400a314b/RMeCab_1.07.tar.gz’ had non-zero exit status
IshidaMotohiro commented 3 years ago

Hello.

Thank you for your message.

The error message seems to be a problem with loading the 64-bit version of the MeCab library. On my Windows machines at hand, I can install without any problems, but I am aware that there are similar error reports.

If you don't care about the 64-bit version, you can use only the 32-bit version by doing the following

devtools::install_github("IshidaMotohiro/RMeCab", INSTALL_opts = "--no-multiarch")

The libmecab64.dll in my repository was built a long time ago. However, there are other people who have built and released 64-bit versions of the library. If you replace the libmecab64.dll in my repository with the latest version of the library, it may work.

https://github.com/ikegami-yukino/mecab https://github.com/shogo82148/mecab

paithiov909 commented 3 years ago

I found that I could reproduce this installation issue (under R4.0.2 for Windows and Rtools4.0.0.28). And this is because the libmecab.dll specified in Makevars.win is not placed in its expected directory when cloning from the HEAD branch. So, unfortunately, just adding INSTALL_opts helps nothing here.

@CLRafaelR

A quick fix is available from this fork. To get things all ready, please follow the steps below:

  1. Download a libmecab.dll, which was built for the architecture that is exactly the same as your R runtime, and ensure to add its location to the 'PATH' environment variable.
  2. Restart an R session and try this snippet.
Sys.setenv(MECAB_LIBS = stringr::str_sub(stringr::str_replace_all(Sys.which("libmecab.dll"), stringr::fixed("\\"), "/"), 1, -14))
remotes::install_github("paithiov909/RMeCab", ref = "update-Makevars", INSTALL_opts = "--no-multiarch")
  1. Prepare a Shift-JIS-encoded dictionary for MeCab. For easy preparation under Windows, you can re-run the MeCab installer (never mattering its architecture here) as an administrator, then answer 'Yes' to the question that saying something like "管理者権限をお持ちのようです。辞書を全ユーザー向けにインストールしますか".
IshidaMotohiro commented 3 years ago

Thank you.

On Windows machines in my environment, I can't install from the above folk, but I guess some can it, depending on environments.

CLRafaelR commented 3 years ago

Apology for the late reply. I appreciate the comments from both of you @IshidaMotohiro and @paithiov909, though I don't have enough time to try either method... Sorry about that, too.

@IshidaMotohiro

I would like to use 64-bit version, so tentatively I'm using the stable version (1.05).

@paithiov909

Although I work with Win 10, I have installed MeCab with UTF-8 encoding to my Win 10, since I also have some programmes which depend on MeCab only with UTF-8 encoding. Should I install another MeCab with Shift-JIS? Does the installation you suggested avoid rewriting the previous dictionary with UTF-8 encoding?

paithiov909 commented 3 years ago

@CLRafaelR Actually, the package seems to work properly with UTF-8 encoded dictionary under Windows. However, in case you use with UTF-8 encoded one, it requires resetting encodings every time you call functions.

Here is an example using RMeCab with UTF-8 dictionary.

res <- RMeCab::RMeCabC(stringi::stri_enc_toutf8("隣の客はよく柿食う客だ"))
dplyr::glimpse(res)
#> List of 9
#>  $ : Named chr "髫」"
#>   ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#>  $ : Named chr "縺ョ"
#>   ..- attr(*, "names")= chr "蜉ゥ隧\x9e"
#>  $ : Named chr "螳「"
#>   ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#>  $ : Named chr "縺ッ"
#>   ..- attr(*, "names")= chr "蜉ゥ隧\x9e"
#>  $ : Named chr "繧医¥"
#>   ..- attr(*, "names")= chr "蜑ッ隧\x9e"
#>  $ : Named chr "譟ソ"
#>   ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#>  $ : Named chr "鬟溘≧"
#>   ..- attr(*, "names")= chr "蜍戊ゥ\x9e"
#>  $ : Named chr "螳「"
#>   ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#>  $ : Named chr "縺\xa0"
#>   ..- attr(*, "names")= chr "蜉ゥ蜍戊ゥ\x9e"
res <- lapply(res, function(elem){ Encoding(elem) <- "UTF-8"; Encoding(names(elem)) <- "UTF-8"; return(elem) })
dplyr::glimpse(res)
#> List of 9
#>  $ : Named chr "隣"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "の"
#>   ..- attr(*, "names")= chr "助詞"
#>  $ : Named chr "客"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "は"
#>   ..- attr(*, "names")= chr "助詞"
#>  $ : Named chr "よく"
#>   ..- attr(*, "names")= chr "副詞"
#>  $ : Named chr "柿"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "食う"
#>   ..- attr(*, "names")= chr "動詞"
#>  $ : Named chr "客"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "だ"
#>   ..- attr(*, "names")= chr "助動詞"

Created on 2021-03-13 by the reprex package (v1.0.0)

This is because RMeCab internally uses the default locale under Windows and this behavior cannot be changed by users. If you prefer UTF-8 encoding, it's ok to use that. Or not, it might be better to manually keep a backup of the present dictionary, recompile Shift-JIS one, copy that to somewhere, and finally redo compiling UTF-8 one.

You can use those system dictionaries by specifying via mecabrc.

res <- RMeCab::RMeCabC("隣の客はよく柿食う客だ", mecabrc = "/MeCab/ipadic-shiftjis/mecabrc")
dplyr::glimpse(res)
#> List of 9
#>  $ : Named chr "隣"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "の"
#>   ..- attr(*, "names")= chr "助詞"
#>  $ : Named chr "客"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "は"
#>   ..- attr(*, "names")= chr "助詞"
#>  $ : Named chr "よく"
#>   ..- attr(*, "names")= chr "副詞"
#>  $ : Named chr "柿"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "食う"
#>   ..- attr(*, "names")= chr "動詞"
#>  $ : Named chr "客"
#>   ..- attr(*, "names")= chr "名詞"
#>  $ : Named chr "だ"
#>   ..- attr(*, "names")= chr "助動詞"

Created on 2021-03-13 by the reprex package (v1.0.0)