在 Mac 上构建 Python 库并遇到平面命名空间错误

发布于 2024-09-24 17:11:41 字数 800 浏览 3 评论 0原文

一般来说,每当我必须在 Mac 上构建 Python 库时,我都会感到遗憾。我通常使用 Boost::Python 取得了相当好的成功,如果我使用 distutils,大多数时间一切正常。

然而,我一直无法弄清楚什么有效/什么无效的确切组合。具体来说,我经常遇到找不到符号的可怕问题,因为我尝试使用的库没有平面命名空间。我尝试切换到 Python 的 MacPorts 版本,然后仅使用 MacPorts 库,而不使用骰子。

我最近遇到的问题是我需要使用的一个工具依赖于 OpenCV 库,而 OpenCV 库又依赖于 FFMPeg 库(实际上,两者都是)。一切都会编译,但是当我执行“导入 MYLIB”时,我得到在平面命名空间中找不到的符号 _pix_fmt_info 。我执行 DYLIB_LIBRARY_PRINT 来查看加载的所有库,果然 libavformat、libavcodec、libavutil 和 libswscale 都已加载。

所以,这是我的问题。具体问题是,有人知道这里可能发生什么吗?我需要手动构建 libffmpeg 吗?我是否在做一些非常愚蠢的事情,比如忘记了一个库(我检查过,我不认为我是......)

更一般地说,是否有一个好的方法来处理平面命名空间问题?我是否总是需要担心包含哪些库?有谁有让事情顺利进行的好方法吗?

有时我确实想念 Linux 的世界。


编辑


抱歉,看来是我自己的愚蠢造成的。我还没有弄清楚确切的问题,但看起来未找到的符号属于与我不同的库(即不是 libffmpeg)。

然而,我仍然对其他人使用平面名称空间的体验感到好奇。

As a general rule, I rue the days whenever I have to build Python libraries on a Mac. I've generally had fairly good success using Boost::Python, and if I use distutils, most of the time everything works correctly.

However, I've never been able figure out the exact combination of what works/what doesn't work. Specifically, I've often run into the dreaded problem of a symbol not being found because the library I'm trying to use doesn't have a flat namespace. I've tried switching to the MacPorts version of Python, and then using only MacPorts libraries, and no dice.

The most recent problem I ran into is a tool I need to use that is dependent on the OpenCV library, which in turn is dependent on the FFMPeg library (actually, both are). Everything compiles, but when I do 'import MYLIB', I get the symbol _pix_fmt_info not found in the flat namespace. I do a DYLIB_LIBRARY_PRINT to view all the libraries loaded, and sure enough libavformat, libavcodec, libavutil, and libswscale are all loaded.

So, here are my questions. The specific question, does anyone have an idea of what might be going on here. Do I need to build libffmpeg by hand? Am I doing something really stupid like forgetting a library (I checked, and I don't think I am..)

More generally, is there a good approach for dealing with the flat namespace issue? Do I always have to worry about which libraries are included? Does anyone have a good recipe for getting things to just work?

Sometimes I do miss the world of Linux..


edit


Sorry, it looks like it was my own stupidity at fault here. I haven't figured out the exact problem, but it looks like the unfound symbol belongs to a different library than I though (i.e. not libffmpeg).

I am still curious about other people's experiences with flat namespaces, however.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦 2024-10-01 17:11:41

选项编译“C”python 绑定时,我看到了这个问题,

-fvisibility=hidden parameter

当我使用mac osx 上的

我的理解是,这类似于平面命名空间问题。

I have seen this issue when I compile the "C" python bindings with the option

-fvisibility=hidden parameter

on mac osx

I am of understanding is that, this is similar to flat namespace issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文