龙芯3A5000编译frp源码生成loongarch架构frps,frpc

一、下载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目录

编译好的资源已上传

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值