extendr: Unable to run on Windows

Currently, I am running stable-gnu-toolchain, with MSYS installed. I’m missing something, that I am not entirely sure how to configure:

cargo build
   Compiling libR-sys v0.1.6
error: failed to run custom build command for `libR-sys v0.1.6`

Caused by:
  process didn't exit successfully: `C:/cargo_target_dir/debug\build\libR-sys-f8980ef9d4a34bd4\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBR_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBR_STATIC
  cargo:rerun-if-env-changed=LIBR_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libR\"", output: Output { status: ExitStatus(ExitStatus(1)), stdout: "", stderr: "Package libR 
was not found in the pkg-config search path.\r\nPerhaps you should add the directory containing `libR.pc\'\r\nto the PKG_CONFIG_PATH environment variable\r\nNo package \'libR\' found\r\n" } }', C:\Users\Tyler\.cargo\registry\src\github.com-1ecc6299db9ec823\libR-sys-0.1.6\build.rs:37:51
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I tried to run pacman -Ss r-base-dev but that doesn’t work for me.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

My rust toolchain produces a libhello.a intermediate lib instead of hello.lib declared in Makevars.win.

Yes, the latest Rust toolchain generates .a for Windows, which many developers don’t notice yet.

c.f. https://github.com/r-rust/hellorust/pull/9

Also not well, equipped to Windows testing (I did quickly try running Windows R on Linux under Wine – which could make life somewhat easier – but while it installs fine it hung when starting a session).

@CGMossa: does the R-devel tree you build include a libR.pc file anywhere? If so, put the directory containing this on your PKG_CONFIG_PATH and the libR-sys build should (famous last words…) pick up your R libraries from there.

If doing your own Windows build doesn’t make such a file, I’d suggest trying to make one by hand for a stopgap, then we can think how best to automate after confirming that works. For reference, the libR.pc file on my Linux machine looks like:

rhome=/usr/lib64/R
rlibdir=${rhome}/lib
rincludedir=/usr/include/R

Name: libR
Description: R as a library
Version: 4.0.2
Libs: -Wl,--export-dynamic -fopenmp  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L${rlibdir} -lR
Cflags: -I${rincludedir} -I${rincludedir}
Libs.private:

Obviously, the paths will change under Windows and you might want to look at the compiler flags (the -specs bit is obviously Redhat-specific, just remove that), but hopefully this gives the general idea…