我读过关于静态和动态库的文章。
我的问题不大具体。
dlopen dlclose :
Benifit of dlopen is we can start the EXE with out
loading the necessary libraries at the begining. Only when we
need we will load the libratries and unload it from the memory.
这是动态链接的行为。
我的问题是,如果我链接到图书馆libUtlities
ld -o EXE main.o -lUtilities
当我运行EXE时,在我
iOS是否失去了使用动态框架的大部分优势?
由于iOS会将所需的所有动态框架复制到应用程序包中,所以它不会在应用程序之间共享动态框架并节省内存。除了与主应用程序及其扩展共享内存。
使用dlOpen的应用程序不能发送到App。这意味着苹果不允许动态框架被正式使用。
旧的苹果文档说动态框架节省了应用程序的启动时间,但是新文档说没有。旧文档过时了吗?以下是比较:
- [make the app launch faster and use less memory once it’s launched](https://developer.apple.com/library/arch
动态库libone.so的代码
void a()
{
printf("--in libone.so a() invoked.\n");
}
使用动态库的应用程序的代码:
#include <stdio.h>
#include <dlfcn.h>
int main()
{
printf("in main.\n");
void (*fptr)();
void *ptr;
// here i used RTLD_NODELETE to available in
我有一个商业c库(a.so),它有几个函数。当您调用a.open()函数时,它会动态地执行对另一个库的dlopen()调用。如果调用a.open('b'),它将打开b.so。如果调用a.open('c'),它将打开c.so。
问题是a.so和b.so共享一个在a.so中定义的全局变量,但被b.so (和c.so等)引用。我能够使用ctype在Python语言中正确加载a.so,并且可以看到Python语言中的所有符号。但是,当我调用a.open('b')时,它试图加载b.so,但返回未定义的符号。
//a.c -source for a.so l
我有一些用于测试的c++代码,其中第一行是对dlopen的调用,试图加载我的共享对象。在点击这一行时,我得到以下错误:
Terminate called after throwing an instance of std::bad_alloc:
what() : St9bad_alloc
我已经提高了内存(空闲的-m现在报告,当我的exe加载到gdb中时,我有大约120MB的空闲空间),但我仍然收到相同的消息。
有没有人知道还有什么可能导致这个问题&我能做些什么来解决它?