当前位置: 技术问答>linux和unix
动态链接库的_init()没被调用
来源: 互联网 发布时间:2015-08-26
本文导语: 我在动态链接库中定义了void _init(void)函数 为什么调用dlopen("x.so", RTLD_NOW)装载该库时,连接器不调用_init()呢?郁闷! man了一下: If the library exports(这个词怎么理解???) a routine named _init, then that code is...
我在动态链接库中定义了void _init(void)函数
为什么调用dlopen("x.so", RTLD_NOW)装载该库时,连接器不调用_init()呢?郁闷!
man了一下:
If the library exports(这个词怎么理解???) a routine named _init, then that
code is executed before dlopen returns. If the same
library is loaded twice with dlopen(), the same file han-
dle is returned. The dl library maintains link counts for
dynamic file handles, so a dynamic library is not deallo-
cated until dlclose has been called on it as many times as
dlopen has succeeded on it
为什么调用dlopen("x.so", RTLD_NOW)装载该库时,连接器不调用_init()呢?郁闷!
man了一下:
If the library exports(这个词怎么理解???) a routine named _init, then that
code is executed before dlopen returns. If the same
library is loaded twice with dlopen(), the same file han-
dle is returned. The dl library maintains link counts for
dynamic file handles, so a dynamic library is not deallo-
cated until dlclose has been called on it as many times as
dlopen has succeeded on it
|
是不是用了C++?
extern "C" void _init(void)
{
}
extern "C" void _init(void)
{
}
|
呵呵,就是这样啊。