---
title: 开源数学库SLEEF使用方法
description: "1. 参考SLEEF官网（https://sleef.org/(https://sleef.org/)）的编译指导编译出动态库libsleef.so。"
url: https://www.hikunpeng.com/document/detail/zh/perftuning/computp-wp/kunpengcomputp_19_0020.html
sourcePath: /source/zh/perftuning/computp-wp/kunpengcomputp_19_0020.html
indexId: 06518a13ce32b7e6361dc4bef76c3452e98793b0f5d9b3bc882020d0b54dee6d60
---
# 开源数学库SLEEF使用方法

1. 参考SLEEF官网（https://sleef.org/(https://sleef.org/)）的编译指导编译出动态库libsleef.so。
2. 因为SLEEF的接口跟libm的标准接口不一致，要让应用在不修改源码的情况下调用SLEEF库，需要增加一层wrap接口。
  wrap接口模板如下，读者根据项目情况补充需要的数学函数接口。

```
// wrapmath.c
#include<sleef.h>
double exp (double a) {
return Sleef_expd1_u10purec(a);
}
double log (double a) {
return Sleef_logd1_u10purec(a);
}
double pow (double a, double b) {
return Sleef_powd1_u10purec(a, b);
}
```


3. 将wrapmath.c编译成libwrapmath.so，编译应用时通过-L指定libwrapmath.so、libsleef.so链接路径即可。
