AIX 动态链接

发布于 2024-09-18 00:51:51 字数 509 浏览 19 评论 0原文

我正在致力于将库移植到 AIX 上。它可以在 Solaris、Windows 和 Linux 上运行,但 AIX 却让我头疼。我正处于构建和运行的阶段,但它链接的一些库存在问题。理想情况下,我希望能够提供一个只需要 c 运行时可用而没有其他依赖项的库。目前我遇到了 libpthread 的问题,我可以看到它是指向 AIX 特定线程库的符号链接。 我的问题是这样的: 如果我不链接 pthread(对于相同的代码库,我似乎不需要在 Solaris 上链接),那么我会得到未定义的符号。没关系,我正在使用 pthreads。如果我链接它,那么它工作正常,除了任何调用应用程序也必须链接到 pthreads。我真的不明白为什么我的调用应用程序(不依赖于 pthread)需要链接到它,只是因为它正在调用链接到共享对象的库?

我在 AIX 6.1 上使用 gcc 4.2.4。

我可以接受一个需要 pthreads 出现在库路径上的库(理想情况下我们会得到一个静态版本),但我对发布一个在客户端上放置链接器请求的库有点不满意。

关于我可能做错了什么有什么想法吗?

I'm working on porting a library onto AIX. It works on Solaris, Windows and Linux but AIX is giving me headaches. I'm at a point where it builds and runs but I have an issue with some of the libraries it's linking in. Ideally I want to be able to ship a library that just requires the c runtime to be available with no other dependencies. At the moment I'm having a problem with libpthread which I can see is a symlink to an AIX specific threading library.
My issue is this:
If I don't link pthread (I don't seem to need to on Solaris for the same code base) then I get undefined symbols. That's fine I am using pthreads. If I link it in then it works fine, except that any calling application also has to link to pthreads. I don't really understand is why does my calling app, which has no dependency on pthread, need to link against it just because it's calling a library which links to the shared object?

I'm on AIX 6.1 using gcc 4.2.4.

I'd be OK with shipping a library that requires pthreads to be present on the library path (ideally we'd get a static version) but I'm a bit unhappy about shipping a library that places linker rqeuirements on the client.

Any ideas on what I might be doing wrong?

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

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

发布评论

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

评论(1

友谊不毕业 2024-09-25 00:51:51

我肯定是在兜圈子。我删除了链接器上的 -shared 标志来解决之前的问题,当然,这使得库静态。因此,这种行为只是正常行为,因为如果您从静态库依赖动态库,则必须将两者链接到您的应用程序中。因此,我已将共享标志放回原处,现在我的一半功能不再可访问。它确实解释了我所看到的问题。

I defeinitely seem to be going in circles. I removed the -shared flag on the linker to resolve an earlier problem and that, of course, makes the library static. So the behaviour is just normal behaviour in that if you depend on a dynamic library from a static one you have to link both into your app. So I've put the shared flag back and now half of my functions are no longer accessible. It does explain the problem I was seeing though.

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