将libpq.5.dylib复制到/usr/lib/libpq.5.dylib [英] copy libpq.5.dylib to /usr/lib/libpq.5.dylib

查看:61
本文介绍了将libpq.5.dylib复制到/usr/lib/libpq.5.dylib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在R中加载软件包,因为文件 libpq.5.dylib 不在/usr/lib/libpq.5.dylib 中.它在/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib

I can't load packages in R because the file libpq.5.dylib is not in /usr/lib/libpq.5.dylib. It is in /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib

我尝试了这一行: sudo ln -s/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib/usr/lib/libpq.5.dylib ,但我得到了此响应: ln:/usr/lib/libpq.5.dylib:不允许操作

I tried this line: sudo ln -s /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/lib/libpq.5.dylib but I get this response: ln: /usr/lib/libpq.5.dylib: Operation not permitted

我该怎么做才能在/usr/lib/libpq.5.dylib 中获取文件而不会引起问题?此解决方案表明,我可能会遇到以下问题行,所以我不知道该怎么办.

What can I do to get the file in /usr/lib/libpq.5.dylib without causing issues? This solution suggests that I may face problems down the line so I don't understand what to do.

推荐答案

您真的不希望在/usr/lib 中使用它.Apple 宣布这是禁区,在较新的 macOS 版本上,它位于只读卷上.除非您愿意进入恢复模式并手动篡改该卷(并且可能在以后的操作系统更新中重复进行此操作),否则这不是要走的路.

You really don't want it in /usr/lib. Apple declared that as off-limits, and on newer macOS versions it lives on a read-only volume. Unless you're willing to go into recovery mode and manually tamper with the volume (and possibly repeat that on future OS updates), this is not the way to go.

让我们解决核心问题:
macOS上的动态库在二进制文件中嵌入了自己的安装路径,链接程序将其复制到与它们链接的二进制文件中.可以使用 install_name_tool 更改此信息(请参阅 man install_name_tool ).

Instead, let's address the core issue:
Dynamic libraries on macOS embed their own install path inside the binary, and the linker copies that into binaries linking against them. This information can be changed with install_name_tool (see man install_name_tool).

  1. 检查dylib的安装名称:

  1. Examine the install name of the dylib:

otool -l /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib | fgrep -A2 LC_ID_DYLIB

如果打印路径已经指向dylib本身(或指向它的符号链接),请将该路径用作下面的 [new_path] ,并跳过步骤2.

If the printed path already points to the dylib itself (or a path that is symlinked to it), use this path as [new_path] below, and skip step 2.

如果dylib的安装名称​​不是指向自身,请运行以下命令:

If the dylib's install name does not point back to itself, run this:

sudo install_name_tool -id /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib

并在下面的 [new_path] 中使用/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib .

对于链接到dylib的二进制文件,运行:

For binaries that link against the dylib, run:

sudo install_name_tool -change /usr/lib/libpq.5.dylib [new_path] [path_to_binary]

这篇关于将libpq.5.dylib复制到/usr/lib/libpq.5.dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆