【发布时间】:2012-01-12 07:53:45
【问题描述】:
我需要动态链接我创建的库。我不确定问题是什么。这一切都正确编译,但我总是将handle 捕获为NULL 指针:
void *handle;
char *error;
handle = dlopen ("./hw11-lib-michaelSchilling.so", RTLD_LAZY);
//same error comes up with full path as well as './hw11...'
if(!handle){
error = dlerror();
printf("%s\n", error);
printf("Error loading library.\n");
exit(1);
}
我无法通过这个错误,我不确定可能出了什么问题。我很确定我已经正确编译了所有内容。以下是我使用的编译步骤:
gcc -rdynamic -c hw11-lib-michaelSchilling.c -o hw11-lib-michaelSchilling.so
gcc hw11-michaelSchilling-4.c -ldl -o hw11-michaelSchilling-4
我收到一条错误消息
只能加载 ET_DYN 和 ET_EXEC。
【问题讨论】:
标签: c dll shared-libraries