一、下载frp最新源码
wget https://github.com/fatedier/frp/archive/refs/tags/v0.59.0.tar.gz
二、解压并进入
tar -xvzf frp-0.59.0.tar.gz
cd frp-0.59.0
三、安装GO环境
wget http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.4.linux-loong64.tar.gz
tar -xvzf go1.22.4.linux-loong64.tar.gz
cd go1.22.4.linux-loong64
sudo cp -r go /usr/local/
export PATH=$PATH:/usr/local/go/bin
输入go version正确显示版本号,安装成功。在国内建议设置国内GOPROXY
export GOPROXY=https://goproxy.cn
四、编译frp
--在frp根目录运行
make
五、解决报错
一通下载模块之后,开始激动人心的编译时刻了。
结果不出意外的DUANG,报错
go version go1.22.4 linux/loong64
go fmt ./...
env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frps -o bin/frps ./cmd/frps
# github.com/templexxx/cpu
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:93:14: undefined array length CacheLineSize or missing type constraint
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:105:14: undefined array length CacheLineSize or missing type constraint
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:113:15: undefined array length CacheLineSize or missing type constraint
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:138:15: undefined array length CacheLineSize or missing type constraint
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:144:19: undefined array length CacheLineSize or missing type constraint
../../go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go:161:19: undefined array length CacheLineSize or missing type constraint
这个应该是模块里没有loongarch64这个架构对应的信息,加上就好了。
--加改权限
chmod 777 ~/go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go
--vim
vim ~/go/pkg/mod/github.com/templexxx/cpu@v0.1.0/cpu.go
--添加缺失变量,在文件开头几行添加如下代码
const CacheLineSize = 32
六、编译成功
然后继续在frp源码目录执行make,很快,就能看到编译成功的提示了:
go version go1.22.4 linux/loong64
go fmt ./...
env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frps -o bin/frps ./cmd/frps
env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frpc -o bin/frpc ./cmd/frpc
编译好的frp文件就在源码的bin目录
编译好的资源已上传