rshared-librariesldhpcopenblas

ld cannot find -lblas -llapack while installing R package clarabel (no root access)


I totally understand if this is an incredibly specific situation which would be better directed to my system administrators instead of StackOverflow, but I thought I'd give it a shot anyway.


I am working in a high-performance computing environment (OpenHPC) in which I do not have root access. Furthermore, the system administrators make some software packages available globally through the LMOD package. For software packages not yet pre-installed, they recommend installing packages through conda or building from source.

I am trying to install the R package clarabel. So far, I have Installed Rust and Cargo using the instructions here and attempted install.packages("clarabel") while in a Conda environment.

Initially, this returned an error containing

/usr/bin/ld: cannot find -lblas
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lgfortran

Simply using module load gnu12/12.2.0 fixed cannot find -lgfortran, but the following issue with blas and lapack persists even after running module load openblas/0.3.21:

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/.cargo/bin:/<sysname>/home/<uname>/.conda/envs/test-env/bin:/<sysname>/software/spack/linux-almalinux9-cascadelake/gcc-11.4.1/openmpi-4.1.6-un62tcwp7nzszg3ezp7cum7yfufdprrc/bin:/opt/ohpc/pub/mpi/libfabric/1.18.0/bin:/opt/ohpc/pub/mpi/ucx-ohpc/1.15.0/bin:/opt/ohpc/pub/libs/hwloc/bin:/opt/ohpc/pub/compiler/gcc/12.2.0/bin:/<sysname>/software/utils/miniconda3/condabin:/<sysname>/home/<uname>/.cargo/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/<sysname>/home/<uname>/.local/bin:/<sysname>/home/<uname>/bin:/<sysname>/home/<uname>/.cargo/bin" VSLANG="1033" "cc" "-Wl,--version-script=/tmp/rustccOUIAd/list" "-Wl,--no-undefined-version" "-m64" "/tmp/rustccOUIAd/symbols.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.00.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.01.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.02.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.03.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.04.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.05.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.06.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.07.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.08.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.09.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.10.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.11.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.12.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.13.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.14.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.clarabel.16fbe4446bc2150f-cgu.15.rcgu.o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/clarabel-92696915beeca31e.18c40nrhdgx63nm9.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps" "-L" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libindexmap-a1870293f17fe811.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libequivalent-13c4f6694b43752a.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libhashbrown-ee45ab3aaf8cbcfb.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libserde_json-742f6f4c6c3e851d.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libitoa-660c93c0233b413a.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libryu-ea35bc21b3a1860f.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libamd-118b2cf4ec891faa.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libblas-d57adeeca52efda7.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libblas_sys-b44f50ded7d7f210.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/liblapack-8ad229381301a14a.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libnum_complex-2841f00af8b703ee.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/liblapack_sys-44be8b0329b78d26.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/liblibc-799eff0394aa6d50.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/liblapack_src-2ccfa321d47d7bdf.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libblas_src-95093de9de072d9b.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libr_src-1aa13c7ad7e0fe1b.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libcfg_if-114d8cc2aed33208.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/liblazy_static-89f61e42525efa42.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libderive_builder-6a575a43a528ce4a.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libserde-293da9773986da66.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libitertools-cfd01c76e19a056c.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libeither-ec1734cb47f0bd2a.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libnum_traits-294e66ee00715eb2.rlib" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libthiserror-6f6728d6b3509612.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d5189b81a4fa4d36.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_abort-005b27ec5a56507a.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-c88c426dd6780435.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-e74540b31113a555.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-8751b61bd13c15cf.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-a8b99dba9f449259.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-f0068d76172a0372.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-c16dfaf47799564e.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-bfa26dd63e299db5.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-75a2330a693e738f.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-76779dce1f7ab63d.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-01c5cc588623cb35.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-07bb9745ec737292.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-6eacdcc91004cefb.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-ae2488b58226c836.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-52acaddcaaba04c6.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-326b78eac9ecd050.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-307ebf19f0f13d30.rlib" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d9076ee5964191bf.rlib" "-Wl,-Bdynamic" "-lblas" "-llapack" "-lgfortran" "-lm" "-lgomp" "-lquadmath" "-lpthread" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/<sysname>/home/<uname>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/RtmpxuuYQp/R.INSTALL845641d0a9cc/clarabel/src/rust/target/release/deps/libclarabel-92696915beeca31e.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: /usr/bin/ld: cannot find -lblas
          /usr/bin/ld: cannot find -llapack
          collect2: error: ld returned 1 exit status
          

error: could not compile `clarabel` (lib) due to 1 previous error

I see that the directory <sysname>/home/<uname>/.conda/envs/<env-name>/lib contains the following files:

where the bottom 4 files are all symbolic links to the first.

I've tried export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<sysname>/home/<uname>/.conda/envs/<env-name>/lib", but the error above remains. I would greatly appreciate your help!

Edit 1

I fixed the error by adding the following two lines to ~/.bashrc:

export LIBRARY_PATH=$LIBRARY_PATH:/hb/home/epawl/.conda/envs/test-env/lib/
export CPATH=$CPATH:/hb/home/epawl/.conda/envs/test-env/include

But now I have a new error. The above -lblas -llapack error occurred when compiling clarabel. Now that clarabel compiles successfully, the rest of the log looks like this:

Finished `release` profile [optimized] target(s) in 2m 33s
rm -Rf /tmp/RtmpN2SScY/R.INSTALL8cafd3612e47c/clarabel/src/rust/.cargo
rm -Rf ./rust/vendor
rm -Rf /tmp/RtmpN2SScY/R.INSTALL8cafd3612e47c/clarabel/src/rust/target/release/build
x86_64-conda-linux-gnu-cc -shared -L/hb/home/epawl/.conda/envs/test-env/lib/R/lib -L/hb/home/epawl/.conda/envs/test-env/lib -o clarabel.so init.o -L/hb/home/epawl/.conda/envs/test-env/lib -lblas -llapack -L/hb/home/epawl/.conda/envs/test-env/lib/R/lib -lR
installing to /hb/home/epawl/R/x86_64-conda-linux-gnu-library/4.3/00LOCK-clarabel/00new/clarabel/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘clarabel’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/hb/home/epawl/R/x86_64-conda-linux-gnu-library/4.3/00LOCK-clarabel/00new/clarabel/libs/clarabel.so':
  /hb/home/epawl/R/x86_64-conda-linux-gnu-library/4.3/00LOCK-clarabel/00new/clarabel/libs/clarabel.so: undefined symbol: savvy_clarabel_solve__ffi
Error: loading failed

I thought I could fix this by further adding to .bashrc the line

export LIBRARY_PATH=$LIBRARY_PATH:/hb/home/epawl/.conda/envs/test-env/lib/
export LIBRARY_PATH=$LIBRARY_PATH:/hb/home/epawl/R/x86_64-conda-linux-gnu-library/4.3/00LOCK-clarabel/00new/clarabel/libs
export CPATH=$CPATH:/hb/home/epawl/.conda/envs/test-env/include

but this changes nothing. conda install -c conda-forge openblas lapack does not help either.

Edit 2: the above code snippet is a typo; I meant conda install -c conda-forge blas lapack, although I have also tried conda install -c conda-forge openblas openblas-devel and this doesn't work either.


Solution

  • It turns out uninstalling R and all packages, deleting all conda packages and environments, and reinstalling everything in a fresh conda environment fixed everything.

    It looks like I had two installations of R which were conflicting, and this caused an issue. Either that, or the recent maintenance (OS upgrade) done on the HPC cluster broke something.