dlopen的问题 [英] Problem with dlopen

查看:89
本文介绍了dlopen的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个使用外部插件的程序,通过调用dlopen()实现在运行时加载的
共享库。

库导出符号,主程序通过调用收集

到dlsym()。


问题是库指的是主要的
程序中的某些符号。但是运行时的链接器无法解析这些未定义的

符号。在共享库中。


我想我可能误解了dlopen()的工作方式 - 可以

有人给我一些建议吗?


谢谢!

Hello,

I have a program that makes use of external plugins, implemented as
shared libraries loaded at runtime through a call to dlopen(). The
libraries export symbols which the main program collects through a call
to dlsym().

The problem is that the libraries refer to certain symbols from the main
program. But the linker at runtime fails to resolve these "undefined
symbols" in the shared library.

I think I may have misunderstood something in how dlopen() works - can
anyone give me some advice?

Thanks!

推荐答案

2008年4月7日17:13,Unknown Soldier写道:
On 7 Apr 2008 at 17:13, Unknown Soldier wrote:

你好,


我有一个程序使用外部插件,实现为在运行时加载的
共享库通过调用dlopen()。

库导出符号,主程序通过调用收集

到dlsym()。


问题是库指的是主要的
程序中的某些符号。但是运行时的链接器无法解析这些未定义的

符号。在共享库中。


我想我可能误解了dlopen()的工作方式 - 可以

有人给我一些建议吗?
Hello,

I have a program that makes use of external plugins, implemented as
shared libraries loaded at runtime through a call to dlopen(). The
libraries export symbols which the main program collects through a call
to dlsym().

The problem is that the libraries refer to certain symbols from the main
program. But the linker at runtime fails to resolve these "undefined
symbols" in the shared library.

I think I may have misunderstood something in how dlopen() works - can
anyone give me some advice?



您是否将主程序与-rdynamic链接?如果没有,只有外部库知道链接时需要的符号

将被导出。

Did you link the main program with -rdynamic? If not, only the symbols
the external library knows it needs at link-time will be exported.


在文章< ; ft ********* @ aioe.org> ;,无名战士< no **** @ nospam.comwrote:
In article <ft*********@aioe.org>, Unknown Soldier <no****@nospam.comwrote:

> I有一个程序使用外部插件,实现为在运行时通过调用dlopen()加载的共享库。
>I have a program that makes use of external plugins, implemented as
shared libraries loaded at runtime through a call to dlopen().



dlopen()不是标准C的一部分,

dlopen()的确切操作取决于您的操作系统。请联系处理您特定操作系统的

开发小组。


如果我从扫描中正确回想起来,在-some-系统上,
向后来自共享库的引用只能通过让共享库本身使用更早的方式来实现

。对象

(例如,在你的情况下,库可能必须dlopen()主要的

可执行文件。)在其他系统中,可能会有类似的效果。 />
而不是必须手动 dlopen()早期的对象,

只是让共享库引用其标题中的对象

足以触发传递dlopen()。然后还有其他

系统,这些限制不适用于它应该只是工作,

和其他系统,它应该只是工作,但只有当

对象向后引用被定义为全局对象。不同的

系统,不同的规则,所以你需要检查-your-

系统的规则。

-

[i] t缺乏背景,可能有或没有意义。

- Walter J. Phillips

dlopen() is not part of standard C, and the exact operations of
dlopen() depend upon your operating system. Please contact a
development group that deals with your particular operating system.

If I recall correctly from my scanning, on -some- systems,
"backwards" referrals from a shared library can only be implemented
by having the shared library itself dlopen the "earlier" object
(e.g., in your case, the library might have to dlopen() the main
executable.) In other systems, a similar effect might be in place
but rather than having to "manually" dlopen() the earlier objects,
just having the shared library refer to the object in its headers
is enough to trigger a transitive dlopen(). And then there are other
systems that these restrictions don''t apply to and it should Just Work,
and other systems on which it should Just Work but only if the
object backwards-referenced was defined as a global object. Different
systems, different rules, so you need to check the rules for -your-
system.
--
"[i]t lacks context, and may or may not make sense."
-- Walter J. Phillips




无名战士 < no **** @ nospam.comwrote in message

"Unknown Soldier" <no****@nospam.comwrote in message

我有一个使用外部插件的程序,实现为共享

通过调用dlopen()在运行时加载的库。图书馆

导出主程序通过调用dlsym()收集的符号。
I have a program that makes use of external plugins, implemented as shared
libraries loaded at runtime through a call to dlopen(). The libraries
export symbols which the main program collects through a call to dlsym().



听起来有人试图实现一些动态链接的类型

在C之上。常规C程序在链接时链接符号,它们不会调用

函数来检索符号列表。

It sounds like someone is trying to implement some type of dynamic linking
on top of C. Regular C programs link symbols at link time, they don''t call
functions to retrieve lists of symbols.


>

问题是库引用了主要的
程序中的某些符号。但是运行时的链接器无法解析这些未定义的

符号。在共享库中。
>
The problem is that the libraries refer to certain symbols from the main
program. But the linker at runtime fails to resolve these "undefined
symbols" in the shared library.



主要有两种可能性。您可能需要链接第三个库,

或者您可能需要在您的用户程序中包含函数/符号,以便链接到
dlopen。

There are two main possibilities. You might need to link a third library,
or you might need to include functions / symbols in your user program for
dlopen to link in.


>

我想我可能误解了dlopen()的工作方式 - 可以

有人给我一些建议吗?
>
I think I may have misunderstood something in how dlopen() works - can
anyone give me some advice?



不幸的是,尽管我可以提供一般性的帮助,但我并不确切知道这个特定系统是如何运作的。您可能想尝试特定于平台的

新闻组。


-

免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm

Unfortunately although I can help in general terms I don''t know exactly how
this specific system works. You might want to try a platform-specific
newsgroup.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


这篇关于dlopen的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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