Skip to content

Cpp Error installing CRAN version of MatrixExtra on Ubuntu 18.04

7 messages · Sebastian Meyer, Dirk Eddelbuettel, David Winsemius +1 more

#
I initially attempted installation of pkg:MatrixExtra with 
`install.packages on my Ubuntu 18.04 LTS system from within RStudio. It 
failed with an error attempting to compile a function named "matmul.cpp" 
so I tried running R from a Terminal session. Same error. Finally I 
downloaded from CRAN and this is the session result of an effort with R 
CMD INSTALL:

(The name of my library is a historical accident, but I'm running R 
version 4.1.2 (2021-11-01) -- "Bird Hippie" and almost all of my other 
1536 packages have been updated without reported errors using 
`update.packages(checkBuilt=TRUE)`

======================================

david at davids:/usr/lib/R$ R CMD INSTALL ~/MatrixExtra_0.1.9.tar.gz
* installing to library ?/home/david/R/x86_64-pc-linux-gnu-library/3.5.1?
* installing *source* package ?MatrixExtra? ...
** package ?MatrixExtra? successfully unpacked and MD5 sums checked
** using staged installation
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
-DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
-fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
-g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c RcppExports.cpp -o 
RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
-DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
-fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
-g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c assignment.cpp -o 
assignment.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
-DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
-fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
-g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c cbind.cpp -o cbind.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
-DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
-I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
-fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
-g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c matmul.cpp -o matmul.o
matmul.cpp: In function ?void gemm_csr_drm_as_dcm(int, int, const int*, 
const int*, const double*, const real_t*, size_t, real_t*, int, int)?:
matmul.cpp:137:41: error: ?ldc? is predetermined ?shared? for ?shared?
 ???????????? private(write_ptr, temp_arr)
 ???????????????????????????????????????? ^
/usr/lib/R/etc/Makeconf:177: recipe for target 'matmul.o' failed
make: *** [matmul.o] Error 1
ERROR: compilation failed for package ?MatrixExtra?
* removing ?/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/MatrixExtra?

=======from an R console session==============================

 > sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:?? /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 ?[1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C
 ?[3] LC_TIME=en_US.UTF-8??????? LC_COLLATE=en_US.UTF-8
 ?[5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8
 ?[7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C
 ?[9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.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.2

Thanks for any suggestions.

David Winsemius
#
On 19 December 2021 at 18:14, David Winsemius wrote:
| I initially attempted installation of pkg:MatrixExtra with 
| `install.packages on my Ubuntu 18.04 LTS system from within RStudio. It 
| failed with an error attempting to compile a function named "matmul.cpp" 
| so I tried running R from a Terminal session. Same error. Finally I 

Well yes. Same system, same compiler and same R.  Can you remind me what

   gcc --version

says on Ubuntu 18.04. It could be that the g++ version may be too old for
current coding practices. You may have to expect such errors to occur more
frequently on ancient system.  Some of us have started to ship packages using
C++14 (which is actually R's default in R 4.1.0 and later unless overridden
to C++11 or lower) and even C++17. Or it could be something else. See below.

| downloaded from CRAN and this is the session result of an effort with R 
| CMD INSTALL:
| 
| (The name of my library is a historical accident, but I'm running R 
| version 4.1.2 (2021-11-01) -- "Bird Hippie" and almost all of my other

You say R 4.1.2 but we see R 3.5.1 below !!

| 1536 packages have been updated without reported errors using 
| `update.packages(checkBuilt=TRUE)`
| 
| ======================================
| 
| david at davids:/usr/lib/R$ R CMD INSTALL ~/MatrixExtra_0.1.9.tar.gz
| * installing to library ?/home/david/R/x86_64-pc-linux-gnu-library/3.5.1?

That is very suspicious.  Why R/x86_64_pc-linux-gnu-library/3.5.1 ?

That looks like an error.  There _was_ a change from R before 4.0 to 4.0.
As I recall you need to rebuild everything for R 4.0.* or R 4.1.*.

| * installing *source* package ?MatrixExtra? ...
| ** package ?MatrixExtra? successfully unpacked and MD5 sums checked
| ** using staged installation
| checking for g++... g++
| checking whether the C++ compiler works... yes
| checking for C++ compiler default output file name... a.out
| checking for suffix of executables...
| checking whether we are cross compiling... no
| checking for suffix of object files... o
| checking whether the compiler supports GNU C++... yes
| checking whether g++ accepts -g... yes
| checking for g++ option to enable C++11 features... none needed

So far it is happy with C++11.

| configure: creating ./config.status
| config.status: creating src/Makevars
| ** libs
| g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
| -DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
| -fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
| -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
| -D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c RcppExports.cpp -o 
| RcppExports.o

And uses C++11

| g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
| -DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
| -fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
| -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
| -D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c assignment.cpp -o 
| assignment.o
| g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
| -DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
| -fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
| -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
| -D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c cbind.cpp -o cbind.o
| g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -DUSE_ROBINMAP 
| -DHAS_LD=1 -DSUPPORTS_RESTRICT=1 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/Rcpp/include' 
| -I'/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/float/include' 
| -fopenmp -fno-trapping-math -fno-math-errno -fvisibility=hidden -fpic? 
| -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=. 
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
| -D_FORTIFY_SOURCE=2 -g? -Wno-ignored-attributes -c matmul.cpp -o matmul.o
| matmul.cpp: In function ?void gemm_csr_drm_as_dcm(int, int, const int*, 
| const int*, const double*, const real_t*, size_t, real_t*, int, int)?:
| matmul.cpp:137:41: error: ?ldc? is predetermined ?shared? for ?shared?
|  ???????????? private(write_ptr, temp_arr)
|  ???????????????????????????????????????? ^
| /usr/lib/R/etc/Makeconf:177: recipe for target 'matmul.o' failed
| make: *** [matmul.o] Error 1
| ERROR: compilation failed for package ?MatrixExtra?
| * removing ?/home/david/R/x86_64-pc-linux-gnu-library/3.5.1/MatrixExtra?

I have never seen that error. No idea.

But again the '3.5.1' seems out of whack with your use of R 4.1.2.

Dirk


| =======from an R console session==============================
| 
|  > sessionInfo()
| R version 4.1.2 (2021-11-01)
| Platform: x86_64-pc-linux-gnu (64-bit)
| Running under: Ubuntu 18.04.5 LTS
| 
| Matrix products: default
| BLAS:?? /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
| LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
| 
| locale:
|  ?[1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C
|  ?[3] LC_TIME=en_US.UTF-8??????? LC_COLLATE=en_US.UTF-8
|  ?[5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8
|  ?[7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C
|  ?[9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C
| [11] LC_MEASUREMENT=en_US.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.2
| 
| Thanks for any suggestions.
| 
| David Winsemius
| 
| _______________________________________________
| R-SIG-Debian mailing list
| R-SIG-Debian at r-project.org
| https://stat.ethz.ch/mailman/listinfo/r-sig-debian
#
Am 20.12.21 um 15:19 schrieb Dirk Eddelbuettel:
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

FWIW, "MatrixExtra" installs without problems for me on "ancient"
I see openblas in your sessionInfo(). Could that be a problem?

Best wishes,

	Sebastian Meyer
#
On 20 December 2021 at 15:48, Sebastian Meyer wrote:
| Am 20.12.21 um 15:19 schrieb Dirk Eddelbuettel:
| >
| > On 19 December 2021 at 18:14, David Winsemius wrote:
| > | I initially attempted installation of pkg:MatrixExtra with
| > | `install.packages on my Ubuntu 18.04 LTS system from within RStudio. It
| > | failed with an error attempting to compile a function named "matmul.cpp"
| > | so I tried running R from a Terminal session. Same error. Finally I
| > 
| > Well yes. Same system, same compiler and same R.  Can you remind me what
| > 
| >     gcc --version
| > 
| > says on Ubuntu 18.04. 
| 
| gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

That should be good enough.
 
| FWIW, "MatrixExtra" installs without problems for me on "ancient"

I am fairly certain that the (accidental ?) mishap of mixing current R,
i.e. his 4.1.2, with a 3.5.1 library is the issue.

It has been so long since I converted from pre-4.0.* that I forgot what the
error message looks like but the arcanae one in David's post may qualify.

| > R version 4.1.2 (2021-11-01)
| > Platform: x86_64-pc-linux-gnu (64-bit)
| > Running under: Ubuntu 18.04.6 LTS
| > 
| > Matrix products: default
| > BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
| > LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
| 
| I see openblas in your sessionInfo(). Could that be a problem?

I do not think. Stable interface, unchanged for decades, hot-swappable.

Dirk
#
On 12/20/21 8:49 AM, Dirk Eddelbuettel wrote:
I also get gcc version:

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
It was just an R user library. I don't have a 3.5.1 library. I'll change 
it to something that doesn't bother you.

Before: from Sys.getenv()

R_HOME???????????????????????? /usr/lib/R
R_INCLUDE_DIR????????????????? /usr/share/R/include
R_LIBS_SITE 
/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER /home/david/R/x86_64-pc-linux-gnu-library/3.5.1/

After changing R_LIBS_USER value:

R_HOME???????????????????????? /usr/lib/R
R_INCLUDE_DIR????????????????? /usr/share/R/include
R_LIBS_SITE 
/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER??????????????????? /home/david/R/Local_user_lib

 > .libPaths( c( "/home/david/R/Local_user_lib", .libPaths()[2:4]) )
 > install.packages("MatrixExtra")
Installing package into ?/home/david/R/Local_user_lib?
(as ?lib? is unspecified)
also installing the dependencies ?Matrix?, ?RhpcBLASctl?, ?float?

trying URL 'https://cloud.r-project.org/src/contrib/Matrix_1.4-0.tar.gz'
Content type 'application/x-gzip' length 2849865 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

trying URL 
'https://cloud.r-project.org/src/contrib/RhpcBLASctl_0.21-247.1.tar.gz'
Content type 'application/x-gzip' length 41291 bytes (40 KB)
==================================================
downloaded 40 KB

trying URL 'https://cloud.r-project.org/src/contrib/float_0.2-6.tar.gz'
Content type 'application/x-gzip' length 1373196 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

trying URL 
'https://cloud.r-project.org/src/contrib/MatrixExtra_0.1.9-1.tar.gz'
Content type 'application/x-gzip' length 218705 bytes (213 KB)
==================================================
downloaded 213 KB

* installing *source* package ?Matrix? ...
** package ?Matrix? successfully unpacked and MD5 sums checked
** using staged installation
** libs

---------------snipped intermediate----------

installing to /home/david/R/Local_user_lib/00LOCK-Matrix/00new/Matrix/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Error: package ?lattice? was installed before R 4.0.0: please re-install it
Execution halted
ERROR: lazy loading failed for package ?Matrix?
* removing ?/home/david/R/Local_user_lib/Matrix?

-------------snipped----

installing to 
/home/david/R/Local_user_lib/00LOCK-MatrixExtra/00new/MatrixExtra/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error: package ?Matrix? 1.2.18 was found, but >= 1.3 is required by 
?MatrixExtra?
Execution halted

------------end copy------------

Ran `update.packages()` again and found quite a few not-yet-updated 
packages, many of them fairly essential, but NOT in the directory you 
were worried about, but rather such as in '/usr/lib/R/site-library' and 
'/usr/lib/R/library'

-----fragment of listing of outdated packages----------

lattice :
 ?Version 0.20-41 installed in /usr/lib/R/library built under R 3.6.3
 ?Version 0.20-45 available at https://cloud.r-project.org

---------


So now I have a bunch of properly updated packages and MatrixExtra 
installs without complaint.


** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation 
path
* DONE (MatrixExtra)

-- 

Thanks for the impetus to change that annoying, but eventually 
misleading, local user library name. I'd been meaning to do that for a 
while, and thanks for the advice to recheck version numbers. I'm not 
quite sure how I got away with this for so long.
#
MatrixExtra 1.9.0 introduced this problem and required something newer
than gcc 8.3.1, e.g. gcc 9.3.1
(https://github.com/david-cortes/MatrixExtra/issues/2).  It's been
fixed in MatrixExtra 0.1.9-1, which is on CRAN since a yesterday or
so.  I've confirmed that this new version installs out of the box on
Ubuntu 18.04 LTS with its default gcc 7.5.0.

/Henrik
On Mon, Dec 20, 2021 at 11:25 AM David Winsemius <dwinsemius at comcast.net> wrote:
#
On 20 December 2021 at 11:25, David Winsemius wrote:
| Ran `update.packages()` again and found quite a few not-yet-updated 
| packages, many of them fairly essential, but NOT in the directory you 
| were worried about, but rather such as in '/usr/lib/R/site-library' and 
| '/usr/lib/R/library'
[...]
| Thanks for the impetus to change that annoying, but eventually 
| misleading, local user library name. I'd been meaning to do that for a 
| while, and thanks for the advice to recheck version numbers. I'm not 
| quite sure how I got away with this for so long.

Glad to hear you are sorted out!

For what it is worth I

 - do not use private user libraries [1]
 - run update.packages() (over all of .libPaths()) daily to weekly

No issues.

Dirk

[1] That is personal preference I reflected in the Debian package for your
actively suppressing them til I was told I can't / shouldn't. Now I just
suppress them at my end by setting the env vars to empty strings (and of
course ensure that /usr/local/lib/R/site-library is group-writeable by a
group I am in.)