r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
173 stars 27 forks source link

Problem using the units package with libraries installed under linuxbrew #293

Closed scizmeli closed 2 years ago

scizmeli commented 2 years ago

I am trying to find a new way to install the external dependencies of the units package (and subsequently many others requiring linking to external libraries) under LINUX using linuxbrew

 brew list udunits
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/bin/udunits2
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/include/ (3 files)
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/lib/ (4 files)
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/share/doc/ (9 files)
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/share/info/ (3 files)
/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/share/udunits/ (6 files)

I install the package using the command

install.packages("units", configure.args='--with-udunits2-lib=/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/lib/ --with-udunits2-include=/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/include')

which works fine. However loading the package is a problem

library(units)
Error: package or namespace load failed for ‘units’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/acizmeli/R/x86_64-pc-linux-gnu-library/4.1/units/libs/units.so':
  libudunits2.so.0: cannot open shared object file: No such file or directory

Manually modifying LD_LIBRARY_PATH does not help either

Sys.setenv(LD_LIBRARY_PATH=paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", "/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/lib/"))
Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server:/home/linuxbrew/.linuxbrew/Cellar/udunits/2.2.28/lib/"

library(units)

I get again

Error: package or namespace load failed for ‘units’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/acizmeli/R/x86_64-pc-linux-gnu-library/4.1/units/libs/units.so':
  libudunits2.so.0: cannot open shared object file: No such file or directory

Is there anything I am missing? Any help would be greatly appreciated.

edzer commented 2 years ago

IMO this has nothing to do with this particular package, but with your wish to have packages that use compiled code linking to a system requirement run on your particular setup. Maybe a question for some more generic forum, like r-package-devel?

scizmeli commented 2 years ago

thx I'll try that