Hello rstudio-fu masters,
I come to you for help with something other people struggled with before, but unfortunately I was not able to find the answer to my problem. I am developing a package with RcppEigen and I have that problem where Rstudio is not able to identify the MatrixXd and VectorXd classes as.... well, classes (it has that member reference base type 'Eigen::VectorXd' (aka 'int') is not a structure or union
message). And yes, my package compiles with no problem, it's just the diagnostics (and auto completion) that have issues.
I'll post my sessionInfo()
and .rs.SetClangDiagnostics(2)
outputs below, but before some context: After rearranging my SSD partitions, I have a fresh install of Ubuntu 20.04.3 and also a fresh install of Rstudio 1.4.1717.
Output of sessionInfo()
:
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=pt_PT.UTF-8 LC_NUMERIC=C LC_TIME=pt_PT.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=pt_PT.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=pt_PT.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1
Output of .rs.setClangDiagnostics(2)
:
Attemping to load libclang for x86_64-pc-linux-gnu
/usr/lib/rstudio/bin/rsclang/libclang.so
(Not Found)
/usr/lib/libclang.so
(Not Found)
/usr/lib/llvm/libclang.so
(Not Found)
/usr/lib64/libclang.so
(Not Found)
/usr/lib64/llvm/libclang.so
(Not Found)
/usr/lib/llvm-10/lib/libclang.so.1
LOADED: 10.0.0
Restarting R session...
CLANG INDEXING: /home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp
# RESTORING PACKAGE COMPILATION CONFIG ----
/home/anthorg/Documents/Work/pkg/bayesPO/.Rproj.user/D26F354E/cpp-compilation-config
{
"args": [
"-I/usr/lib/llvm-10/lib/clang/10.0.0/include",
"-I/usr/include/c++/9",
"-I/usr/include/x86_64-linux-gnu/c++/9",
"-I/usr/include/c++/9/backward",
"-I/usr/lib/gcc/x86_64-linux-gnu/9/include",
"-I/usr/local/include",
"-I/usr/include/x86_64-linux-gnu",
"-I/usr/include",
"-I/usr/lib/R/site-library/Rcpp/include",
"-I/usr/lib/R/site-library/RcppEigen/include",
"-I/home/anthorg/R/x86_64-pc-linux-gnu-library/4.1/RcppProgress/include",
"-std=gnu++14",
"-I/usr/share/R/include",
"-DNDEBUG",
"-fopenmp",
"-Ilibsrc",
"-fopenmp",
"-I/usr/lib/R/site-library/Rcpp/include",
"-fpic",
"-fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=.",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2"
],
"pch": "RcppEigen",
"is_cpp": true,
"hash": "163276610716328251401632825144",
"compiler": "12341514841039914196"
}
# GENERATING PRECOMPILED HEADERS ----
[
"-I/usr/lib/llvm-10/lib/clang/10.0.0/include",
"-I/usr/include/c++/9",
"-I/usr/include/x86_64-linux-gnu/c++/9",
"-I/usr/include/c++/9/backward",
"-I/usr/lib/gcc/x86_64-linux-gnu/9/include",
"-I/usr/local/include",
"-I/usr/include/x86_64-linux-gnu",
"-I/usr/include",
"-I/usr/lib/R/site-library/Rcpp/include",
"-I/usr/lib/R/site-library/RcppEigen/include",
"-I/home/anthorg/R/x86_64-pc-linux-gnu-library/4.1/RcppProgress/include",
"-I/usr/share/R/include",
"-DNDEBUG",
"-fopenmp",
"-Ilibsrc",
"-fopenmp",
"-I/usr/lib/R/site-library/Rcpp/include",
"-fpic",
"-fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=.",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
"-I/usr/lib/R/site-library/RcppEigen/include",
"-std=gnu++14"
]
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:130:19: error: use of undeclared identifier '__builtin_ia32_addss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:136:19: error: use of undeclared identifier '__builtin_ia32_subss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:142:19: error: use of undeclared identifier '__builtin_ia32_mulss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:148:19: error: use of undeclared identifier '__builtin_ia32_divss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:242:10: error: use of undeclared identifier '__builtin_ia32_andps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:248:10: error: use of undeclared identifier '__builtin_ia32_andnps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:254:10: error: use of undeclared identifier '__builtin_ia32_orps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:260:10: error: use of undeclared identifier '__builtin_ia32_xorps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:288:19: error: use of undeclared identifier '__builtin_ia32_movss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:298:19: error: use of undeclared identifier '__builtin_ia32_movss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:326:19: error: use of undeclared identifier '__builtin_ia32_movss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:336:19: error: use of undeclared identifier '__builtin_ia32_movss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:380:19: error: use of undeclared identifier '__builtin_ia32_cmpgtps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:386:19: error: use of undeclared identifier '__builtin_ia32_cmpgeps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:410:19: error: use of undeclared identifier '__builtin_ia32_cmpngtps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:416:19: error: use of undeclared identifier '__builtin_ia32_cmpngeps'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:602:19: error: use of undeclared identifier '__builtin_ia32_cvtsi2ss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:618:19: error: use of undeclared identifier '__builtin_ia32_cvtsi642ss'
/usr/lib/gcc/x86_64-linux-gnu/9/include/xmmintrin.h:625:19: error: use of undeclared identifier '__builtin_ia32_cvtsi642ss'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
# COMPILATION ARGUMENTS ----
[
"-I/usr/lib/llvm-10/lib/clang/10.0.0/include",
"-I/usr/include/c++/9",
"-I/usr/include/x86_64-linux-gnu/c++/9",
"-I/usr/include/c++/9/backward",
"-I/usr/lib/gcc/x86_64-linux-gnu/9/include",
"-I/usr/local/include",
"-I/usr/include/x86_64-linux-gnu",
"-I/usr/include",
"-I/usr/lib/R/site-library/Rcpp/include",
"-I/usr/lib/R/site-library/RcppEigen/include",
"-I/home/anthorg/R/x86_64-pc-linux-gnu-library/4.1/RcppProgress/include",
"-std=gnu++14",
"-I/usr/share/R/include",
"-DNDEBUG",
"-fopenmp",
"-Ilibsrc",
"-fopenmp",
"-I/usr/lib/R/site-library/Rcpp/include",
"-fpic",
"-fdebug-prefix-map=/build/r-base-QwogzP/r-base-4.1.1=.",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
"-include-pch",
"/tmp/Rtmpb8atEH/rstudio/libclang/precompiled/RcppEigen/C61381C8/0.3.3.9.1-x86_64-pc-linux-gnu-80725-10.0.0/RcppEigen-std=gnu++14.pch",
"-v"
]
(Creating new index)
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir:
Found candidate GCC installation: /../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
ignoring nonexistent directory "libsrc"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/lib/R/site-library/Rcpp/include"
ignoring duplicate directory "/usr/include/c++/9"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"
ignoring duplicate directory "/usr/include/c++/9/backward"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/local/include"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/lib/llvm-10/lib/clang/10.0.0/include"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/9/include
/usr/lib/R/site-library/Rcpp/include
/usr/lib/R/site-library/RcppEigen/include
/home/anthorg/R/x86_64-pc-linux-gnu-library/4.1/RcppProgress/include
/usr/share/R/include
/usr/include/c++/9
/usr/include/x86_64-linux-gnu/c++/9
/usr/include/c++/9/backward
/usr/local/include
/usr/lib/llvm-10/lib/clang/10.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
/home/anthorg/Documents/Work/pkg/bayesPO/src/utils.h:31:14: error: member reference base type 'const Eigen::MatrixXd' (aka 'const int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/utils.h:32:59: error: member reference base type 'const Eigen::MatrixXd' (aka 'const int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:21:42: error: member reference base type 'Eigen::VectorXd' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:22:30: error: member reference base type 'Eigen::VectorXd' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:26:18: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:26:39: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:27:18: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:29:24: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:29:49: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:30:26: error: member reference base type 'Eigen::VectorXi' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:33:15: error: invalid operands to binary expression ('Eigen::VectorXd' (aka 'int') and 'double')
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:35:27: error: member reference base type 'int' is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:37:34: error: member reference base type 'int' is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:70:41: error: subscripted value is not an array, pointer, or vector
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:71:33: error: member reference base type 'Eigen::VectorXd' (aka 'int') is not a structure or union
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:74:66: error: subscripted value is not an array, pointer, or vector
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:76:43: error: subscripted value is not an array, pointer, or vector
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:76:70: error: subscripted value is not an array, pointer, or vector
/home/anthorg/Documents/Work/pkg/bayesPO/src/runBayesPO.cpp:78:64: error: subscripted value is not an array, pointer, or vector
fatal error: too many errors emitted, stopping now [-ferror-limit=]
TOTAL MEMORY: 42 mb (runBayesPO.cpp)
PERFORMANCE 2548 ms (runBayesPO.cpp)
Something funny: I have an old Mac which I also use occasionally. It is running R 4.1.1 with Rstudio 1.4.1106 and... it doesn't show diagnostics errors with the same code! Go figure...
IMPORTANT: I seem to have found part of the problem. If I run Rcpp::Rcpp.package.skeleton()
, there is no problem with the diagnostics in the cpp file it creates. However, by adding RcppEigen in the LinkingTo section of the DESCRIPTION file, suddenly even Rcpp's classes give diagnostic errors. So it seems that Rstudio is searching for the RcppEigen headers somewhere it shouldn't and it screws up even Rcpp's headers.
I hope someone can help figure what I'm supposed to do with my system or Rstudio config so I can code on my PC. The package is growing in size and I could really use some functioning coding diagnostics.
Thanks in advance!