简体   繁体   English

安装 opam 包时链接到非标准路径中的库

[英]Linking to a library in a non-standard path when installing an opam package

I am trying to install an opam package (conf-zmq.0.1) in a cluster.我正在尝试在集群中安装 opam 包 (conf-zmq.0.1)。 I have no root access, and I have manually installed the zmq library in /path/to/libzmq.我没有 root 访问权限,我在 /path/to/libzmq 中手动安装了 zmq 库。

The command "opam install zmq" fails at the following point:命令“opam install zmq”在以下几点失败:

[ERROR] The compilation of conf-zmq failed at "/hpc/eb/compilerwrappers/compilers/cc test.c -I/usr/local/include -L/usr/local/lib -lzmq".

This seems simple, but after looking throgh the manual, I have been unable to find how to tell opam to change -L/usr/local/lib to -L/path/to/libzmq.这看起来很简单,但是在查看手册后,我一直无法找到如何告诉 opam 将 -L/usr/local/lib 更改为 -L/path/to/libzmq。

Any help on this would be very appreciated.对此的任何帮助将不胜感激。

It is not possible to tell opam anything about the C compiler linking rules, neither about OCaml linking rules, or any other compilation rules, as opam is much above this.不可能告诉 opam 任何有关 C 编译器链接规则的信息,也不能告诉 opam 任何关于 OCaml 链接规则或任何其他编译规则的信息,因为 opam 远高于此。 The responsibility of opam is to find a package with the best suiting version, download it, and install using the build and configuration scripts that are provided by the package maintainer. opam 的职责是找到一个最适合版本的包,下载它,并使用包维护者提供的构建和配置脚本进行安装。

Although opam provides facilities for package configuration parameters, the conf-zmq maintainer is not utilizing them and do not provide any parameterization for their package.尽管 opam 为包配置参数提供了便利,但 conf-zmq 维护者并未使用它们,也不为其包提供任何参数化。 In fact, there are no other options to pass the installation test of the conf-zmq package, other than installing them in the hardcoded location.实际上,除了将它们安装在硬编码位置之外,没有其他选项可以通过 conf-zmq 包的安装测试。 You can submit a bug-report or ask the maintainer for further support.您可以提交错误报告或向维护者寻求进一步支持。 You can find all the links in the opam file of the package.您可以在软件包的 opam文件中找到所有链接。

The good news is that there is a workaround.好消息是有一种解决方法。 If the package description is broken, then you can always download the package to your local filesystem, fix it, and the pin the fixed version.如果包描述被破坏,那么您可以随时将包下载到本地文件系统,修复它,并固定固定版本。 And opam will now use your local version. opam 现在将使用您的本地版本。 If you want to distribute your package, you will need to push your changes upstream of course (if you want it to be available to the general public (ie, via ocaml.org), or just have your own opam repository (that may contain only one package or many packages).如果你想分发你的包,你当然需要将你的更改推送到上游(如果你希望它对公众可用(即,通过 ocaml.org),或者只有你自己的 opam 存储库(可能包含只有一包或多包)。

But for starters, here the first drop-in instructions, first obtain the sources either by cloning it from the GitHub repository or just by issuing the following command:但是对于初学者来说,这里是第一个插入说明,首先通过从GitHub 存储库克隆它或仅通过发出以下命令来获取源代码:

opam source zmq

You can then change your working directory to the folder that opam has created for you, eg, for me it was然后您可以将您的工作目录更改为 opam 为您创建的文件夹,例如,对我来说是

cd zmq.5.1.3/

Then (the hardest part) hack the package to make it installable on your system.然后(最难的部分)破解该软件包以使其可安装在您的系统上。 (The first thing that you need is to drop the dependency on the broken conf-zmq package). (您需要做的第一件事是放弃对损坏的conf-zmq包的依赖)。 Once you're ready, or think that you're ready just do一旦你准备好了,或者认为你已经准备好了就去做

opam pin add .

opam should pick the package names from the opam files, but if it won't do this see opam pin --help for more options. opam 应该从 opam 文件中选择包名称,但如果它不这样做,请参阅opam pin --help以获取更多选项。 It will then try to install the pinned package.然后它会尝试安装固定包。 If it fails, then continue hacking and doing如果失败,那么继续hacking并做

opam update
opam reinstall zmq # or install

Once the patch is ready, you can either embed it in your automation or create your own opam repository.补丁准备好后,您可以将其嵌入到您的自动化中或创建您自己的 opam 存储库。 It is also very easy, just create a new GitHub repo (or clone the ocaml/opam-repository, not recommended) then copy the package definition that you would like to change (for us it would be packages/zmq/zmq.5.1.3/ ) and apply your hacks to the opam and configurations scripts.这也很简单,只需创建一个新的 GitHub 存储库(或克隆 ocaml/opam-repository,不推荐),然后复制您要更改的包定义(对我们来说,它将是packages/zmq/zmq.5.1.3/ ) 并将您的技巧应用于 opam 和配置脚本。 If your hacks also include changes to the zmq source code, you can format them as patches and add use the patches stanza in your opam file to apply them on the fly.如果您的 hack 还包括对 zmq 源代码的更改,您可以将它们格式化为补丁并在您的 opam 文件中添加使用patches节来即时应用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM