gpt4 book ai didi

mac 上的 python-config ldflags

转载 作者:行者123 更新时间:2023-12-05 05:29:13 25 4
gpt4 key购买 nike

我在 OS X 10.6.2 上遇到 python-config --ldflags 问题。

使用我的非系统 python.org python 安装:

robin-mbp:~ robince$ which python
/Library/Frameworks/Python.framework/Versions/2.5/bin/python
robin-mbp:~ robince$ python-config --ldflags
-L/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config -ldl -lpython2.5

但是如果我用上面的 LDFLAGS 构建一个嵌入 Python 的 c 程序,它会导致系统 python 被嵌入。似乎 -lpython2.5 在 -L 路径中的那个之前首先选择系统 python。

到目前为止,我让它工作的唯一方法是

LDFLAGS=-F/ -framework Python

但是当谈到分发时,我真的很想能够使用 python-config。

库搜索路径是怎么回事,导致它按预期停止工作?根据手册页 -L 路径应该在默认路径之前搜索。

我可以将“忘记默认搜索路径并仅搜索用 -L 指定的路径”之类的任何选项添加到 python-config 输出以使其正常工作吗?

或者有什么方法可以从路径上的任何 Python 中提取工作框架标志(这将适用于用户正在使用的任何内容,即系统、python.org、macports 或自己构建的)?

最佳答案

很抱歉回答我自己的问题,但我在 pythonmac-sig 邮件列表上得到了惊人的迅速回复,我也在那里提问。这是当前 python 的错误:http://bugs.python.org/issue7541

建议的解决方法:

The easiest workaround is to open a terminal window and execute the following commands:

cd /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config ln -s libpython2.5.a libpython2.5.dylib

This will ensure that the OSX linker knows that libpython is a shared library and links to this library. By default the OSX linker searches for a .dylib on the entire linker path and only then looks for .a files.

编辑:进一步更新:

If you can add mac-specific flags in your build system you could add -Wl,-search_paths_first to LDFLAGS on OSX, this ensures that the linker looks for both .dylib and .a files in a directory on the link path before moving to the next directory.

关于mac 上的 python-config ldflags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1929180/

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