目标:使用C++成功调用C++文件生成的.so文件
场景:最近在设计交易系统,有使用到C++中间件层调用后台服务的状态,现在简单熟悉下怎样用C++动态的去调用.so文件。
过程:
1. 一般的交易系统后台系统都有中间件层和后台业务逻辑层,写技术的玩玩中间件,写业务的专注于后台业务逻辑处理。今天我们看看怎么样去调用.so文件。
首先列出test.h文件
#ifndef _test_h_
#define _test_h_
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespacestd;
class Test
{
private:
int a;
int b;
public:
int getResult( char* pXMLIn, char* pXMLOut);
};
#endif
#ifdef__cplusplus //注意 这里是双下划线
extern"C"
{
#endif
int getCResult(char* pXMLIn, char* pXMLOut);
#ifdef__cplusplus
}
#endif