当前位置: 技术问答>linux和unix
请教:dlopen总是打不开动态库文件??
来源: 互联网 发布时间:2015-10-01
本文导语: //---------------------------------------------------------------- //main.c #include #include #include #include"types.h" struct resource rcs; int main() { int i; void *handle; void (*myfcn)(void *); const char* errmsg; char* dir = "./policy.so"; handle=dlopen(dir,...
//----------------------------------------------------------------
//main.c
#include
#include
#include
#include"types.h"
struct resource rcs;
int main()
{
int i;
void *handle;
void (*myfcn)(void *);
const char* errmsg;
char* dir = "./policy.so";
handle=dlopen(dir, RTLD_NOW);
if(handle == NULL) {
fprintf(stderr, "Failed to load '%s'n", dir);
exit(EXIT_FAILURE);
}
dlerror();
myfcn = dlsym(handle, "init_policy");
if((errmsg = dlerror()) != NULL) {
fprintf(stderr, "Didn't find policy_entry");
exit(EXIT_FAILURE);
}
rcs.aaa = malloc(6);
rcs.bbb = malloc(6);
for(i = 0; i
//main.c
#include
#include
#include
#include"types.h"
struct resource rcs;
int main()
{
int i;
void *handle;
void (*myfcn)(void *);
const char* errmsg;
char* dir = "./policy.so";
handle=dlopen(dir, RTLD_NOW);
if(handle == NULL) {
fprintf(stderr, "Failed to load '%s'n", dir);
exit(EXIT_FAILURE);
}
dlerror();
myfcn = dlsym(handle, "init_policy");
if((errmsg = dlerror()) != NULL) {
fprintf(stderr, "Didn't find policy_entry");
exit(EXIT_FAILURE);
}
rcs.aaa = malloc(6);
rcs.bbb = malloc(6);
for(i = 0; i