ubuntu frp 自编译。本文不能按顺序来 请自己理解
go run:go run 编译并直接运行程序,它会产生一个临时文件(但不会生成 .exe 文件),直接在命令行输出程序执行结果,方便用户调试。
go build:go build 用于测试编译包,主要检查是否会有编译错误,如果是一个可执行文件的源码(即是 main 包),就会直接生成一个可执行文件。
go install:go install 的作用有两步:第一步是编译导入的包文件,所有导入的包文件编译完才会编译主程序;第二步是将编译后生成的可执行文件放到 bin 目录下($GOPATH/bin),编译后的包文件放到 pkg 目录下($GOPATH/pkg)。
---------------------
作者:路人1994
来源:CSDN
原文:https://blog.csdn.net/zyz770834013/article/details/78656985
版权声明:本文为博主原创文章,转载请附上博文链接!

export GOROOT="/usr/lib/go-1.9/"
export PATH="$PATH:$GOROOT/bin"
export GOPATH=~/go/
复制一份
/home/hu/gogo/frp/vendor/golang.org
到 ~/go/src
*@*:~/go/src$ ls
github.com golang.org
*@*:~/gogo/frp$ env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o ./frpc_windows_amd64.exe ./cmd/frpc
*@*:~/gogo/frp$ env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o ./frps_windows_amd64.exe ./cmd/frps
客户端编译不过?
执行
*@*:~/gogo/frp$ go get github.com/inconshreveable/mousetrap
*@*:~/gogo/frp$ gp get github.com/spf13/cobra
最近编译不过
发现缺少库
下载地址 。
https://github.com/golang/go
下面那句是编辑
leafpad ~/.bashrc
export GOROOT=$HOME/go
export GOPATH=$HOME/go
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
source ~./bashrc
上面那句是刷新
https://glide.sh/
root@11:~/gopath/src/github.com/fatedier/frp# glide install
[WARN]The name listed in the config file (github.com/fatedier/frp) does not match the current location (.)
[INFO]Downloading dependencies. Please wait...
[INFO]--> Fetching github.com/pmezard/go-difflib
[INFO]--> Fetching github.com/rakyll/statik
[INFO]--> Fetching github.com/rodaine/table
[INFO]--> Fetching github.com/stretchr/testify
[INFO]--> Fetching github.com/templexxx/reedsolomon
[INFO]--> Fetching github.com/fatedier/kcp-go
[INFO]--> Fetching github.com/templexxx/cpufeat
[INFO]--> Fetching github.com/templexxx/xor
[INFO]--> Fetching github.com/tjfoc/gmsm
[INFO]--> Fetching github.com/armon/go-socks5
[INFO]--> Fetching github.com/julienschmidt/httprouter
[INFO]--> Fetching github.com/davecgh/go-spew
[INFO]--> Fetching github.com/golang/snappy
[INFO]--> Fetching github.com/docopt/docopt-go
[INFO]--> Fetching github.com/gorilla/websocket
[INFO]--> Fetching github.com/fatedier/beego
[INFO]--> Fetching github.com/klauspost/reedsolomon
[INFO]--> Fetching github.com/pkg/errors
[INFO]--> Fetching github.com/klauspost/cpuid
[INFO]--> Fetching github.com/vaughan0/go-ini
[INFO]--> Fetching github.com/xtaci/kcp-go
[INFO]--> Fetching github.com/xtaci/smux
[INFO]--> Fetching golang.org/x/crypto
[INFO]--> Fetching golang.org/x/net
[WARN]Unable to checkout golang.org/x/crypto
[ERROR]Update failed for golang.org/x/crypto: Cannot detect VCS
[WARN]Unable to checkout golang.org/x/net
[ERROR]Update failed for golang.org/x/net: Cannot detect VCS
[ERROR]Failed to install: Cannot detect VCS
Cannot detect VCS
[common]
#server_addr一定要写域名形式,不要直接写IP地址
server_addr = frp2.chuantou.org
server_port = 7000
privilege_token = www.xxorg.com
protocol = kcp
# 标注你的代理名字,随便选择一个跟别人不一样即可
user = myname [askm2]
type = http
local_ip = 127.0.0.1
local_port = 80
# 选择一个可用的子域名,你的访问地址将会是http://xxorg.frp2.chuantou.org
subdomain = askm2 [common]
server_addr = frpzj.lu8.win
server_port = 7000
privilege_token = frp888
log_file = frpc.log
log_level = info
log_max_days = 3 [web]
privilege_mode=true
type = http
local_port = 2222
local_ip = 127.0.0.1
custom_domains = ask.frp.lu8.win [chiness中国_50002]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 80
use_gzip = true
use_encryption = true
authentication_timeout = 0
remote_port = 50002 [chiness中国http_50003]
privilege_mode = true
type = tcp
local_ip = 192.168.2.1
local_port = 80
authentication_timeout = 0
remote_port = 50003 [common]
server_addr = frpzj.lu8.win
server_port = 7000
privilege_token = frp888
log_file = frpc.log
log_level = info
log_max_days = 3 [chiness中国_50002]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 5900
use_gzip = true
use_encryption = true
authentication_timeout = 0
remote_port = 50002 [chiness中国http_50003]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 80
use_gzip = true
use_encryption = true
authentication_timeout = 0
remote_port = 50003
如何压缩Golang 编译出的可执行文件大小
先给结论:可以减少到原来的29%
最近在写一个TLScat小工具 Github.com/mengzhuo/tlscat 源文件仅仅2KB不到,但是用 go build tlscat.go 编译出来的有4.6MB!

后来发现这个Golang的1.5才会解决的问题 Issue #6853 all: binaries too big and growing 可是,我就不信这个邪,于是搜索到了go build的一些用法 go build -ldflags "-s -w" '-s' 相当于strip掉符号表, 但是以后就没办法在gdb里查看行号和文件了。 '-w' flag to the linker to omit the debug information 告知连接器放弃所有debug信息 这样一来就只有3MB了
然后发现在Mac平台下,还有upx这样神一般的存在。
UPX achieves an excellent compression ratio and offers very fast decompression.
简而言之,upx就是对可执行文件进行压缩,然后可以已极快的速度解压并运行
可以用brew快速安装upx brew install upx upx 可执行文件
Golang在windows下交叉编译linux程序
1、下载相关程序。
Golang下载:http://www.golangtc.com/download
Git下载:http://git-scm.com/download/
TDM-GCC下载:http://tdm-gcc.tdragon.net/download
2、Go编译环境配置
安装 TDM-GCC,程序会自动设置PATH环境变量,如果没有设置成功请手动设置。
安装Go,安装完后需要设置GOROOT,GOPATH,GOBIN,PATH环境变量,
其中
GOROOT为你的Go安装跟目录
GOPATH为你go程序开发目录,go get后的包也会下载到该目录。
GOBIN为你的go运行目录,运行 go install 命令后,程序会被安装到该目录。
PATH为你Go程序根目录,用于能够通过控制台调用go命令。
3、配置交叉编译环境
在Go根目录下的src目录,新建一个build.bat文件,并复制内容如下:

set CGO_ENABLED=0
set GOROOT_BOOTSTRAP=C:/Go
::x86块
set GOARCH=386
set GOOS=windows
call make.bat --no-clean set GOOS=linux
call make.bat --no-clean set GOOS=freebsd
call make.bat --no-clean set GOOS=darwin
call make.bat --no-clean
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::x64块
set GOARCH=amd64
set GOOS=linux
call make.bat --no-clean
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::arm块
set GOARCH=arm
set GOOS=linux
call make.bat --no-clean
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set GOARCH=386
set GOOS=windows
go get github.com/nsf/gocode
pause

我的Go程序版本是1.6,需要设置GOROOT_BOOTSTRAP变量为Go的安装目录,否则执行时会报错。
然后运行build.bat,等待结束。
该程序会编译其他平台编译Go需要的库和编译文件。
完成后,在cmd命令行下依次执行:
set GOOS=linux
set GOPACH=amd64
go build -o -x APPNAME main.go
编译后的文件会出现在main.go相应的目录下。
现在go 的跨平台编译比较简单了,
set GOARCH=amd64
set GOOS=linux
然后就可以了, go build出来的就是linux 64 位的可执行程序了
ubuntu frp 自编译。本文不能按顺序来 请自己理解的更多相关文章
- Ubuntu 15.04 编译UE4 for Linux版
源 起 Unreal Engine 4 是全球最先进的Realtime Illumination & Physical 引擎: 长期以来,UE4都只有Windows版和Mac版,今年终于向Li ...
- 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正
前题: 在前几个月的时候,写了一篇笔记,说的是kernel compile的事情,当时经验不足,虽说编译过了,但有些地方写的有错误--因为当时的理解是有错误的.今天一一更正,记录如下: 前文笔记链接: ...
- Ubuntu通过源代码编译安装Octave 4.0
本教程/笔记,意在指导在Ubuntu及其它Linux系统上怎样通过源代码安装Octave. Octave简单介绍 Octave是GNU旗下取代matlab的数学工具软件,语法与matlab高度兼容.而 ...
- ubuntu下boost编译安装
ubuntu下boost编译安装 boost 安装 1.依赖安装 apt-get install mpi-default-dev libicu-dev python-dev python3-dev l ...
- ubuntu下如何编译C语言
ubuntu下如何编译C语言 如果没有gcc编译器的话,使用以下命令获取 ~# sudo apt-get install gcc同时要下载辅助工具 ~# sudo apt-get instal ...
- Ubuntu 14.04 编译 Android 4.2.2 for Tiny4412
. . . . . 在学校里是用 Redhat 6.4 编译的 Android 4.2.2 很顺利,把源码包拷贝到笔记本上的 Ubuntu 14.04 上再编译遭遇了各种坑,所以便有了这篇博客记录解决 ...
- Ubuntu 18.04 编译 ijkplayer
Ubuntu 18.04 编译 ijkplayer 1. 配置安装源 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu 2. 配置好安装源后,安装一些组 ...
- 在Ubuntu安装go编译环境
在Ubuntu安装go编译环境 好记性不如烂笔头,所以趁热打铁记录下golang编译环境的安装过程. 首先下载一些依赖包: sudo apt-get install bison ed gawk gcc ...
- Ubuntu/CentOS下编译Nginx最基本参数
Ubuntu/CentOS下编译Nginx安装基本参数,做个记录: groupadd www useradd -g www www ./configure --user=www --group=www ...
随机推荐
- IOS实时监控上传下载速度
在开发中要获取网络类型是很简单的,导入Reachability直接获取状态就行了,现在我们要做一个类似下载器的那种实时把上传下载速度显示出来. 需要用到的头文件 使用Reachability 要测速度 ...
- 51nod1459【二级最短路】
标签说的是BFS... 太菜,不知道怎么BFS...是不是spfa写,就叫BFS...感觉不是.... 只是二级最短路的写法,直接搞就很容易了,简单题: #include <bits/stdc+ ...
- 我叫mt2.0更新公告
一.2.0版<PVP的远征>军费发放 简体服<我叫MT>2.0版本<PVP的远征>更新在即!为备战新版本,我们宣布10天后(3月10日)发放军费振奋军心. 简体服3 ...
- 15.split分割注意事项
1.v = 'k1,v1- k2,v2- k3,v3-'变成一个字典{'k1':'v1','k2':'v2','k3:'v3'...} 变成一个字典 {'k1':'v1','k2':'v2','k3: ...
- java 程序从linux 上接收不可见字符
近期在写一个简单的小java程序,希望在运行java 程序时,从shell 中接收参数,并且参数的内容为不可见字符. 开始时还觉得可以使用"\"之类的转义符来写,后来发现java程 ...
- css文本之蛇
文本之蛇 css把文本当做一行来处理,把他们放在一个看不见的盒子里面.盒子遇到容器的外边界会折行.所有的文本属性都应用于这个盒子,而不是包含文本的容器. 最有用的8个文本属性 文本缩进(text-in ...
- Yac - PHP扩展
1:首先你要安装Git [root@localhost]# git clone https://github.com/laruence/yac 2:进入yac目录进行配置 [root@localhos ...
- nutzboot dubbo zookeeper简单使用
提供方和消费方properties 配置基本差不多 nutz.application.name这个值不一样 提供方配置自动端口就行server.port=0 消费方一般需要对外提供web服务配置ip和 ...
- Java | 基础归纳 | JPA
https://www.javacodegeeks.com/2015/04/jpa%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B.html JPA 全称====>Jav ...
- DRF教程6-分页
rest框架提供自定义分页样式,让你修改再每个页面上显示多少条数据, pagination API 可以: 分页链接作为响应内容的一部分 分页链接包含在响应头里,比如Content-Range or ...