国产探花免费观看_亚洲丰满少妇自慰呻吟_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動態庫中的資源全部內容了,希望大家多多支持武林網~

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贵州省| 吉安县| 濮阳县| 任丘市| 寿阳县| 普兰店市| 霸州市| 鲜城| 济源市| 布拖县| 普格县| 巨野县| 延津县| 蛟河市| 清河县| 剑川县| 宁德市| 司法| 青浦区| 绥德县| 德兴市| 吴忠市| 南漳县| 长宁县| 台南市| 高阳县| 万年县| 阳曲县| 满洲里市| 新竹县| 新兴县| 陇西县| 泾阳县| 西华县| 康平县| 攀枝花市| 武川县| 商南县| 读书| 兰坪| 搜索|