文件列表
- boost_alias.cpp
- madd.cpp
- madd.h
源码
- boost_alias.cpp
#include <boost/dll/alias.hpp>
#include <boost/dll/shared_library.hpp>
#include<iostream>
#include <dlfcn.h>
#include"madd.h"
using namespace std;
int f1();
int f2();
int f3();
int main(){
f3();
return 0;
}
int f3(){
//dlerror();
void *lib_dl = dlopen("./libmadd.so",RTLD_LAZY);
if(lib_dl == NULL){
cout<<"load so error"<<endl;
return -1;
}
int (*pfm)(int , int ) = NULL;
pfm = (int (*)(int , int ))dlsym(lib_dl,"madd");
cout<<"pfm ="<<*pfm <<endl;
const char *dlmsg = dlerror();
if(dlmsg){
cout<<"load func error"<<endl;
return -1;
}
if(pfm){
cout<<(*pfm)(2,3)<<endl;
}
else {
cout<&