# free5gc总结
## 一、编译
准备系统环境,建议内核在 5.0.0-23-generic以上
>OS: Ubuntu 18.04
>gcc 7.3.0
>Go 1.12.9 linux/amd64
>kernel version 5.0.0-23-generic (MUST for UPF)
**本机为Ubuntu 20.04,kernel为 5.4.0**
```bash
renzt@free5gc:~/go/src/go.mongodb.org$ uname -a
Linux free5gc 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```
按照github提示进行操作,但有些代码问题,需要自行处理。
### 1、提前准备mongodb驱动
在$GOPATH/go.mongo.org/目录下执行 **(注意不要使用官网mongo驱动,不兼容)** :
```bash
mkdir -p $GOPATH/go.mongo.org
git clone https://gitee.com/qiuyuyang/mongo-go-driver.git
```
将目录mongo-go-driver复制为mongo-driver:
```bash
cd $GOPATH/go.mongo.org/
cp mongo-go-driver mongo-driver
```
### 2、准备缺失go库
因下载受限,需要设置代理
```bash
export GOPROXY=https://goproxy.io
```
默认缺少crypto库,需要自行准备:
```bash
renzt@free5gc:~/go/src/golang.org/x$ git clone https://github.com/golang/crypto.git
```
### 3、代码bug
/home/renzt/go/src/free5gc/lib/ngap/ngapSctp/sctp.go
代码bug:失败时也会正常返回,导致panic。
不过全部调试通过后,程序走不到这块逻辑,也不影响测试结果,可忽略。
```golang
ln, err := sctp.ListenSCTPExt("sctp", addr,
sctp.InitMsg{NumOstreams: 3, MaxInstreams: 5, MaxAttempts: 4, MaxInitTimeout: 8})
if err != nil {
logger.NgapLog.Errorf("failed to listen: %v", err)
}
logger.NgapLog.Infof("Listen on %s", ln.Addr())
return ln
```
**第二个bug,需要改代码**
```bash
../lib/MongoDBLibrary/ap