Bash on Ubuntu on Windows, 运行 Linux 安装 Windows 程序的命令

Bash on Ubuntu on Windows, Run Linux Commands to Install a Windows Program

我是 Linux 的新手,但我在安装没有 windows 二进制文件的 R 软件包时遇到了很多麻烦。我宁愿不安装完整的 Linux 安装并移动所有内容。从 Windows Interoperability 来看, 似乎 这样应该是可能的。 我想在下面的块引用中执行 GNU R package cplexAPI 文档中的任何一个选项。我试过:

C:\Users\zejas>bash
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ R CMD INSTALL cplexAPI_1.3.2.tar.gz
The program 'R' is currently not installed. You can install it by typing:
sudo apt-get install r-base-core
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$

基于示例:

$/mnt/c/Windows/System32/notepad.exe

我试过了:

zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ $/mnt/C/Program Files/Microsoft/MRO-3.3.1/bin
bash: $/mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ /mnt/C/Program Files/Microsoft/MRO-3.3.1/bin
bash: /mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ /mnt/C/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
bash: /mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ $/mnt/C/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
bash: $/mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ C/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
bash: C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ $/mnt/C/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
bash: $/mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ /mnt/C/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
bash: /mnt/C/Program: No such file or directory
zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ /mnt/c/Program Files/Microsoft/MRO-3.3.1/bin/R.exe
 bash: /mnt/c/Program: No such file or directory
 zejas@DESKTOP-JASON:/mnt/c/Users/zejas$ /mnt/c/Windows/System32/notepad.exe
 bash: /mnt/c/Windows/System32/notepad.exe: cannot execute binary file: Exec format error

有什么想法吗?

----------------------------------------------------------------------------

Linux and MacOS X installation

----------------------------------------------------------------------------

The locations of the CPLEX callable library and the CPLEX include directory can be found in /README.html>, where is the CPLEX installation directory. Also have a look at the variables CLNFLAGS and COPT in the example Makefile of your CPLEX installation. There, the variable CPLEXLIBDIR points to the callable library directory.

There are several ways of installing the cplexAPI package:

1) Set variables PKG_CFLAGS, PKG_CPPFLAGS and PKG_LIBS directly, e.g.:

R CMD INSTALL --configure-args =" \ PKG_CFLAGS='-m64 -fPIC' \
PKG_CPPFLAGS='-I/cplex/include' \
PKG_LIBS='-L${CPLEXLIBDIR} -lcplex -m64 -lm -pthread'" \
cplexAPI_x.x.x.tar.gz

PKF_CFLAGS is optional, but both PKG_CPPFLAGS and PKG_LIBS must be given.

2) Use --with-cplex-:

--with-cplex-include=PATH with PATH being the include directory of CPLEX

--with-cplex-lib=PATH with PATH being the directory containing the callable library of CPLEX.

R CMD INSTALL --configure-args=" \ --with-cplex-include=/path/to/include/dir \ --with-cplex-lib=/path/to/lib/dir" cplexAPI_x.x.x.tar.gz

When using --with-cplex-, both arguments --with-cplex-lib and --with-cplex-include must be given.

--with-cplex-link=-l... libraries to path to the linker during compilation.

If --with-cplex-link is not given, '-lcplex -lm -pthread' will be used as default.

--with-cplex-cflags=... optional CFLAGS

A further argument can be used in order to use the debuging routines included in the C API of CPLEX:

--with-cplex-check=PATH with PATH being the directory containing the file check.c from the CPLEX examples directory.

R CMD INSTALL --configure-args=" \
--with-cplex-lib='/path/to/lib/dir' \ --with-cplex-include='/path/to/include/dir' \ --with-cplex-link='-lcplex -m64 -lm -pthread' \ --with-cplex-cflags='-m64 -fPIC' \ --with-cplex-check='/path/to/examples/dir/examples/src/c'" \ cplexAPI_x.x.x.tar.gz

3) Give the location of the CPLEX installation:

--with-cplex-dir=PATH with PATH being the CPLEX directory. This is not the CPLEX installation directory , it is the directory including the lib/ include/ and examples/ directory. Usually this is /cplex.

R CMD INSTALL --configure-args="
--with-cplex-dir='/cplex'" \ cplexAPI_x.x.x.tar.gz

This procedure will take the first system type and library format it finds. Information reqired for the compilation is taken from the example Makefile.

4) Give no information:

R CMD INSTALL cplexAPI_x.x.x.tar.gz This procedure will try to find the CPLEX interactive optimizer, or the CPLEX_BIN environment variable pointing to the CPLEX interactive optimizer will be used. The directory two levels above is used as CPLEX directory, all other information is taken from teh CPLEX example Makefile as in #3 above.

首先,要访问其中包含空格的路径,请使用双引号:

"/mnt/c/Program Files/Microsoft/MRO-3.3.1/bin/R.exe"

其次,如果您拥有 Windows 10 或更高版本的构建 14951,则您只能 运行 Windows 来自 bash 的程序。这在您链接到的 MSDN 页面顶部注明:

The Windows Subsystem for Linux can invoke native Windows binaries and be invoked from a Windows command line. This feature is available to Windows 10 users running Anniversary Update build 14951.

此版本仍在 Windows 内部版本中,因此尚未普遍可用(截至 2017 年 1 月 16 日,最新的 GA 版本为 14393)。现在,如果您需要此功能,可以安装 cbwin

第三,来自Linuxshell的运行ning R不会神奇地解决预编译二进制包不可用的原因:cplexAPI依赖于CPLEX Studio应用程序来自 IBM,您仍然需要让 R 包可用。假设您确实有这个可用,您可以下载 cplexAPI 源代码并从 Windows 编译包 ,而无需触及 bash shell.