Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation error: 'mutex' in namespace 'std' does not name a type #12

Open
KoichiHashikawa opened this issue Apr 19, 2021 · 3 comments

Comments

@KoichiHashikawa
Copy link

KoichiHashikawa commented Apr 19, 2021

Hello,

I tried to install presto in anaconda/jupyter environment.

devtools::install_github("immunogenomics/presto") gave an error below and failed. I am wondering if there are any suggestions.

* installing *source* package 'presto' ...
** using staged installation
** libs
g++  -std=gnu++11 -I"C:/Users/Koichi/envs/multiome/lib/R/include" -DNDEBUG  -I'C:/Users/Koichi/envs/multiome/Lib/R/library/Rcpp/include' -I'C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include'        -O2 -Wall  -march=x86-64 -mtune=generic -c RcppExports.cpp -o RcppExports.o
In file included from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo:153,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadilloForward.h:49,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadillo.h:31,
                 from RcppExports.cpp:4:
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_bones.hpp:680:29: error: 'mutex' in namespace 'std' does not name a type
  680 |   arma_aligned mutable std::mutex cache_mutex;
      |                             ^~~~~
In file included from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo:153,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadilloForward.h:49,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadillo.h:31,
                 from RcppExports.cpp:4:
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_bones.hpp:1:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
  +++ |+#include <mutex>
    1 | // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
In file included from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo:625,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadilloForward.h:49,
                 from C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/RcppArmadillo.h:31,
                 from RcppExports.cpp:4:
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp: In member function 'void arma::SpMat<eT>::sync_cache() const':
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:6660:7: error: 'cache_mutex' was not declared in this scope
 6660 |       cache_mutex.lock();
      |       ^~~~~~~~~~~
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp: In member function 'void arma::SpMat<eT>::sync_csc() const':
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:6712:7: error: 'cache_mutex' was not declared in this scope
 6712 |       cache_mutex.lock();
      |       ^~~~~~~~~~~
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp: In instantiation of 'void arma::SpMat<eT>::init(const arma::SpMat<eT>&) [with eT = double]':
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:685:3:   required from 'arma::SpMat<eT>& arma::SpMat<eT>::operator=(const arma::SpMat<eT>&) [with eT = double]'
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:5688:5:   required from 'void arma::SpMat<eT>::steal_mem(arma::SpMat<eT>&) [with eT = double]'
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:249:11:   required from 'arma::SpMat<eT>::SpMat(arma::SpMat<eT>&&) [with eT = double]'
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/fn_speye.hpp:77:10:   required from here
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:5056:9: error: 'const class arma::SpMat<double>' has no member named 'cache_mutex'
 5056 |       x.cache_mutex.lock();
      |       ~~^~~~~~~~~~~
C:/Users/Koichi/envs/multiome/Lib/R/library/RcppArmadillo/include/armadillo_bits/SpMat_meat.hpp:5062:9: error: 'const class arma::SpMat<double>' has no member named 'cache_mutex'
 5062 |       x.cache_mutex.unlock();
      |       ~~^~~~~~~~~~~
make: *** [C:/Users/Koichi/envs/multiome/lib/R/etc/x64/Makeconf:229: RcppExports.o] Error 1
ERROR: compilation failed for package 'presto'
* removing 'C:/Users/Koichi/envs/multiome/Lib/R/library/presto'
[I 10:22:32.611 NotebookApp] Saving file at /Documents/R/habenula/installation.ipynb

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] pillar_1.6.0      compiler_4.0.3    prettyunits_1.1.1 base64enc_0.1-3  
 [5] remotes_2.3.0     tools_4.0.3       testthat_3.0.2    digest_0.6.27    
 [9] pkgbuild_1.2.0    uuid_0.1-4        pkgload_1.2.1     jsonlite_1.7.2   
[13] evaluate_0.14     memoise_2.0.0     lifecycle_1.0.0   rlang_0.4.10     
[17] rstudioapi_0.13   IRdisplay_1.0     cli_2.4.0         curl_4.3         
[21] IRkernel_1.1.1    fastmap_1.1.0     repr_1.1.3        withr_2.4.2      
[25] desc_1.3.0        fs_1.5.0          vctrs_0.3.7       devtools_2.4.0   
[29] rprojroot_2.0.2   glue_1.4.2        R6_2.5.0          processx_3.5.1   
[33] fansi_0.4.2       sessioninfo_1.1.1 pbdZMQ_0.3-5      purrr_0.3.4      
[37] callr_3.6.0       magrittr_2.0.1    usethis_2.0.1     ps_1.6.0         
[41] ellipsis_0.3.1    htmltools_0.5.1.1 utf8_1.2.1        cachem_1.0.4     
[45] crayon_1.4.1    
@slowkow
Copy link
Member

slowkow commented Apr 19, 2021

This thread might provide more details about your issue. Maybe this thread has some relevant hints?

https://stackoverflow.com/questions/14191566/c-mutex-in-namespace-std-does-not-name-a-type

My understanding is that this error seems to be caused by the C++ compiler that you use on Windows.

I'm not sure exactly what might fix your issue, but maybe we can try a few ideas?

Idea 1

Could you please update to the latest version of RcppArmadillo by running install.packages("RcppArmadillo")? Then try to install presto?

Does that work?

Idea 2

This issue seems to be related. Could we try the solution proposed there?

Can we disable the use of mutex by changing how the package is compiled? The CRAN documentation has tips on Customizing package compilation.

As Dirk said in the related issue, you might try something like this:

Open your ~/.R/Makevars file and look for CXXFLAGS and CXX11FLAGS:

CXXFLAGS= -g -O3 -Wall -DARMA_DONT_USE_CXX11_MUTEX
CXX11FLAGS=	-g -O3 -Wall -DARMA_DONT_USE_CXX11_MUTEX

I don't know what your file looks like, but try adding the string -DARMA_DONT_USE_CXX11_MUTEX to the end of the settings for CXXFLAGS and CXX11FLAGS.

Does that work?

@slowkow slowkow changed the title Installation error Installation error: 'mutex' in namespace 'std' does not name a type Apr 19, 2021
@KoichiHashikawa
Copy link
Author

KoichiHashikawa commented Apr 20, 2021

Thanks so much for the detailed answer.

Previous errors are solved and I think it gets very close, but still have an error an the end.

** testing if installed package can be loaded from temporary location
Warning: package 'data.table' was built under R version 4.0.5
Error: package or namespace load failed for 'presto' in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/Users/Koichi/envs/Integrate/Lib/R/library/00LOCK-presto/00new/presto/libs/x64/presto.dll':
  LoadLibrary failure:  The specified procedure could not be found.

Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/Koichi/envs/Integrate/Lib/R/library/presto'
Warning message:
In i.p(...) :
  installation of package 'C:/Users/KOICHI~1/AppData/Local/Temp/RtmpEjc3AU/file1cfc46030b6/presto_1.0.0.tar.gz' had non-zero exit status

@slowkow
Copy link
Member

slowkow commented Apr 21, 2021

Here's a Stackoverflow thread matching the query LoadLibrary failure: The specified procedure could not be found.

https://stackoverflow.com/questions/13497222/the-specified-module-could-not-be-found-in-r

From that thread, here is what I might suggest:

  1. Delete the folder C:/Users/Koichi/envs/Integrate/Lib/R/library/00LOCK-presto
  2. Close R or RStudio, and start a new R session.
  3. Run devtools::install_github("immunogenomics/presto")

I hope that solves the issue!

If you still have an issue, then I might guess that you could have some issues with your PATH environment variable on Windows, or some issues with using multiple C++ compilers instead of one compiler (e.g. package1 compiled with compiler1, and package2 compiled with compiler2).

If possible, please consider sharing what specific steps helped to solve the issue, so other people who find this thread in the future can learn from our discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants