zoukankan      html  css  js  c++  java
  • dlsym用法

    1. 包含头文件 #include<dlfcn.h>

    2. 函数定义 void *dlsym(void *handle, const char* symbol);

    handle是使用dlopen函数之后返回的句柄,symbol是要求获取的函数的名称,函数,返回值是void*,指向函数的地址,供调用使用

    dlsym与dlopen的以如下例子解释:

    #include<dlfcn.h>

    void * handle = dlopen("./testListDB.so",RTLD_LAZY);

    如果createListDB函数定义为int32_t createListDB(std::string);

    那么dlsym的用法则为:int32_t  (*create_listDB)(std::string) = reinterpret_cast<int32_t (*)(std::string)>(dlsym(handle, "createListDB"))

    createListDB库函数的定义要用extern来声明,这样在主函数中才能通过createListDB来查找函数,

  • 相关阅读:
    关于重构的一些方法
    java基础 逻辑
    java基础
    去重和数组排序
    表单验证
    JS实例5
    window.document对象
    JS实例4
    JS实例3
    JS实例2
  • 原文地址:https://www.cnblogs.com/qianqiannian/p/11762651.html
Copyright © 2011-2022 走看看