gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:22:07 28 4
gpt4 key购买 nike

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

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,则只能从 bash 运行 Windows 程序。这在您链接到的 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 Insider 版本中,因此尚未普遍可用(截至 2017 年 1 月 16 日,最新的 GA 是版本 14393)。现在,您可以安装 cbwin如果您需要此功能。

第三,从 Linux shell 运行 R 不会神奇地解决预编译二进制包不可用的原因:cplexAPI 依赖于 IBM 的 CPLEX Studio 应用程序,您仍然需要为 R 包提供它上类。假设您确实拥有它,您可以下载 cplexAPI 源代码并从 Windows 编译程序包,而无需接触 bash shell。

关于r - Bash on Ubuntu on Windows,运行Linux命令安装Windows程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41667234/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com