grimbough / rhdf5filters

Distributing additional HDF5 compression filters as an R package. Intended to be used with rhdf5, however the compiled filters can also be used with external applications.
https://bioconductor.org/packages/rhdf5filters/
BSD 2-Clause "Simplified" License
5 stars 6 forks source link

Problems with gcc in Linux Pop Os! #17

Closed blackhill86 closed 1 year ago

blackhill86 commented 2 years ago

Hello! I hope the developers can help me with this issue. I've been trying to install rhdf5filters because it is a dependency for rhdf5 library. However, when I try to install rhdf5filters I see the following message:

BiocManager::install("rhdf5filters")
'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for details

replacement repositories:
    CRAN: https://cloud.r-project.org

Bioconductor version 3.16 (BiocManager 1.30.18), R 4.2.1 (2022-06-23)
Installing package(s) 'rhdf5filters'
trying URL 'https://bioconductor.org/packages/3.16/bioc/src/contrib/rhdf5filters_1.9.0.tar.gz'
Content type 'application/x-gzip' length 854620 bytes (834 KB)
==================================================
downloaded 834 KB

* installing *source* package ‘rhdf5filters’ ...
** using staged installation
Rscript execution error: No such file or directory
configuring the BLOSC filter...
x86_CPU=true
checking for gcc... gcc
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 we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether C compiler accepts -msse2... yes
checking whether C compiler accepts -mavx2... yes
checking for gcc __builtin_cpu_init function... (cached) true
checking for x86 sse2 instruction support... yes
checking for x86 avx2 instruction support... yes
configure: creating ./config.status
config.status: creating src/blosc/lib/blosc-1.20.1/Makefile
config.status: creating src/blosc/Makefile
configure:    BZIP2_LIB=bzip2/libH5Zbz2.so
configure:    BLOSC_LIB=blosc/libH5Zblosc.so
configure:    LZF_LIB=lzf/libH5Zlzf.so
configure: creating ./config.status
config.status: creating src/blosc/lib/blosc-1.20.1/Makefile
config.status: creating src/blosc/Makefile
config.status: creating src/Makevars
** libs
make -C blosc
make[1]: Entering directory '/tmp/RtmpAI3Tmy/R.INSTALL1030b371596b0/rhdf5filters/src/blosc'
make -C lib/snappy-1.1.1
make[2]: Entering directory '/tmp/RtmpAI3Tmy/R.INSTALL1030b371596b0/rhdf5filters/src/blosc/lib/snappy-1.1.1'
g++ -std=gnu++14 -g -O2 -ffile-prefix-map=/build/r-base-4xhVZt/r-base-4.2.1=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fpic -I"" -c snappy.cc
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:13: snappy.o] Error 1
make[2]: Leaving directory '/tmp/RtmpAI3Tmy/R.INSTALL1030b371596b0/rhdf5filters/src/blosc/lib/snappy-1.1.1'
make[1]: *** [Makefile:54: lib/snappy-1.1.1] Error 2
make[1]: Leaving directory '/tmp/RtmpAI3Tmy/R.INSTALL1030b371596b0/rhdf5filters/src/blosc'
make: *** [Makevars:30: blosc/libH5Zblosc.so] Error 2
ERROR: compilation failed for package ‘rhdf5filters’
* removing ‘/home/esteban/R/x86_64-pc-linux-gnu-library/4.2/rhdf5filters’

The downloaded source packages are in
        ‘/tmp/RtmpWOh65B/downloaded_packages’ 

I already tried updating R , also I tried with the devel version also tried GitHub version. I don't think it is my gcc library because other packages are running fine, but I'm willing to try possible solutions. This is my session info, thanks for any help you can suggest.

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               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    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] BiocManager_1.30.18 lavaan_0.6-12.1716 

loaded via a namespace (and not attached):
 [1] prettyunits_1.1.1 ps_1.7.1          withr_2.5.0       rprojroot_2.0.3   crayon_1.5.1      R6_2.5.1          jsonlite_1.8.0   
 [8] stats4_4.2.1      rlang_1.0.3       cli_3.3.0         curl_4.3.2        remotes_2.4.2     callr_3.7.0       pbivnorm_0.6.0   
[15] tools_4.2.1       compiler_4.2.1    processx_3.6.1    pkgbuild_1.3.1    mnormt_2.1.0      tmvnsim_1.0-2
grimbough commented 2 years ago

It looks like the system library locations are not being passed to the linker correctly. In your ouput you have:

g++ -std=gnu++14 -g -O2 -ffile-prefix-map=/build/r-base-4xhVZt/r-base-4.2.1=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fpic -I"" -c snappy.cc

on my Linux Mint machine the same line is:

g++ -std=gnu++14 -march=native -fpic -I/usr/local/include -I"/mnt/data/R-lib/4.2-bioc_3.16/Rhdf5lib/include" -c snappy.cc

The important part is that I have -I/usr/local/include -I"/mnt/data/R-lib/4.2-bioc_3.16/Rhdf5lib/include" and you have -I"", indicating that the configure step isn't finding the correct loctions on your machine.

These are dectected in https://github.com/grimbough/rhdf5filters/blob/697eaa248f4227f00ff30b952b6abfbac87019aa/configure.ac#L17-L36

What do you get if you run the following two lines in a terminal?

R CMD config CPPFLAGS
Rscript -e 'cat(system.file("include", package="Rhdf5lib"))'
blackhill86 commented 2 years ago

Thanks for the quick answer, I installed Rdhf5lib but you are right, library paths are missing, this is what I get:


Rscript -e 'cat(system.file("include", package="Rhdf5lib"))'
Rscript execution error: No such file or directory

But, If I do it opening R I get this:

cat(system.file("include", package="Rhdf5lib"))
/home/esteban/R/x86_64-pc-linux-gnu-library/4.2/Rhdf5lib/include

I guess I'll check all the locations you listed above.

grimbough commented 2 years ago

How did you install R? Was it via a package manager or did you build it yourself?

I think when I've encoutered the "Rscript execution error: No such file or directory" error, it's because the R binary has been moved from the location it was in when Rscript was created.

blackhill86 commented 2 years ago

I installed it with the package manager sudo apt install r-base. You are right, I never use Rscript on my local computer, that's why I didn't notice it is not located. In fact, that's the main problem in this issue. I will try to google how to fix the problem. I believe it is something related to root permissions administrated by Pop Os!

blackhill86 commented 2 years ago

I've found the solution. The problem is Pop Os! assigns Rscript to root group and root ownership, I changed both (group and ownership) to my user, and it didn't work for a reason I still don't understand. I had to run R with sudo which installs all packages on '/usr/local/lib/R/site-library'. This is not an ideal solution, but it worked.

Thanks for your help. It was not an issue with the package, it was Linux permissions.