C++ Python模块在MacOS上链接
我正在MacOS上构建C ++ Python模块。
在我的计算机上,我有Python,安装在目录/library/frameworks/python.framework/versions/3.9
中。我正在指定python的目录为-i/library/frameworks/python.framework/framework/versions/3.9/headers
和libraries Directory as > limral/frame/python.framework/versions/versions/versions /3.9/lib -lpython3.9
。
因此,它可以在我的计算机和其他机器上构建良好,并在其中安装到/library/frameworks/python.framework/versions/versions/3.9
中。
但是,当我将图书馆移至机器时,将Python安装到另一个文件夹中,例如/usr/usr/local/cellar/ [email  procepted] /3.9.12/frameworks/python.frameworks/versorwork/versorwork/versions/3.9
,我会得到导入模块错误。
otool -l _mymodule.so
命令返回过硬编码的绝对路径到/library/frameworks/python.frameworks/versorwork/versions/3.9
。我知道,我可以使用install_name_tool更改路径,但是我不想询问并解释我的模块用户来执行此操作,并建立符号链接。
如何使模块更便宜,而Python安装路径独立?
I'm building a C++ python module on MacOS.
On my machine I have python, installed in directory /Library/Frameworks/Python.framework/Versions/3.9
. I'm specifing python includes directory as -I/Library/Frameworks/Python.framework/Versions/3.9/Headers
and libraries directory as -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9
.
So it builds good and runs good on my machine and other machines, where python is installed into /Library/Frameworks/Python.framework/Versions/3.9
.
But when I move my library to machine, where python is installed into another folder, like /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9
, I'm getting import module error.
otool -L _mymodule.so
command returns hardcoded absolute path to /Library/Frameworks/Python.framework/Versions/3.9
. I know, that I can change the path using install_name_tool, but I don't want to ask and explain my module users to do that, as well as to make a symlink.
How can I make module more portable and python install path independent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论