aiaiask.com©

开花即结果 提问即答案

linux下写一个dlopen函数可以调用的so动态库,给出代码
原始问题:

linux下写一个dlopen函数可以调用的so动态库,给出代码

include <stdio.h>

include <dlfcn.h>

int main()
{

// open the library 
void *handle = dlopen("./libhello.so", RTLD_LAZY); 

// reset errors 
dlerror();  

// load the symbol from library (function add) 

typedef int (*hello_t)();

hello_t hello = (hello_t)dlsym(handle, "hello");

const char *dlsym_error = dlerror();    

 if (dlsym_error) {     

      fprintf(stderr, "%s  

", dlsym_error);

      exit(1);     }        printf("calling hello(): %d  

", hello()); // close the library dlclose(handle); }

linux下写一个dlopen函数可以调用的so动态库,给出代码
https://www.aiaiask.com/ask/7782.html
AI / 模型Siliconflow
时间 / DATEApril 10, 2023, 5:30 PM
语言zh-CN
IP / 区域广西壮族自治区梧州市

Prev:甲流症状