国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

c++實現加載so動態庫中的資源

2020-01-26 14:19:10
字體:
來源:轉載
供稿:網友

實例如下:

#include <stdio.h> #include <dlfcn.h> #include <stdlib.h> #include <iostream> //編譯命令 g++ -m32 EncodeOrDecode.cpp -ldl -o edcode//名字通過nm -D xxxxxx.so獲取using namespace std;int main(int argc,char **argv){void *handle = dlopen("./libpub_com_service.so",RTLD_LAZY);if(!handle){printf("open libpub error ,dlerror=%s/n",dlerror());return -1;}string src = "05d7151349b7fe9b54306d90f9c938b3";string desKey = "pub.%?d5";//58printf("start ..src=[%s].....size=[%d]./n",src.c_str(),src.size());//encode typedef string (*encode_t)(const string encodeSrc,const string encodeKey);encode_t encode = (encode_t)dlsym(handle,"_ZN10NS_PUB_API9DesEncodeESsSs");if(!encode){printf("not found encode function ,dlerror= %s /n",dlerror());dlclose(handle);return -1;}string encodeStr = encode(src,desKey);printf("get the encode function success ..encodeStr=[%s].....size=[%d]/n",encodeStr.c_str(),encodeStr.size());//decode typedef bool (*decode_t)(const string decodeSrc,const string decodeKey,string &outResult);decode_t decode = (decode_t)dlsym(handle,"_ZN10NS_PUB_API9DesDecodeESsSsRSs");if(!decode){printf("not found decode function ,dlerror= %s /n",dlerror());dlclose(handle);return -1;}string decodeOut;bool ret = decode(encodeStr,desKey,decodeOut);printf("get the decode function success ...ret=[%d]...decodeOut=[%s].....size=[%d]/n",ret,decodeOut.c_str(),decodeOut.size());//enddlclose(handle);return 0;}

以上就是小編為大家帶來的c++實現加載so動態庫中的資源全部內容了,希望大家多多支持武林網~

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 通江县| 周至县| 锡林浩特市| 拜泉县| 湘乡市| 吴旗县| 永平县| 泰宁县| 绍兴市| 来宾市| 土默特左旗| 滨海县| 隆子县| 秦安县| 临西县| 嘉荫县| 阿图什市| 尼勒克县| 吉隆县| 鱼台县| 永宁县| 台江县| 沅陵县| 芜湖市| 门源| 九龙坡区| 兴山县| 朝阳市| 乌恰县| 霍邱县| 南城县| 鄂温| 青川县| 景德镇市| 石家庄市| 彰武县| 佛坪县| 大冶市| 桂平市| 乐平市| 万荣县|