編譯ngrok的Windows、Mac的客戶端

    ngrok是一個ddns服務,爲內網機器綁定一個公網域名,方便開發調試遠程接口(如微信開發)。
linux

以前博文裏面寫過如何安裝ngrok,可是因爲公司裏面的研發工程師的筆記本有windows本和mac本,因此本次主要講怎麼生成windows、mac客戶端。git

    準備工做:須要參考http://nanchunle.blog.51cto.com/9244770/1710295,安裝完成ngrokgithub

1、編譯Windwos客戶端golang

cd /usr/local/go/src
GOOS=windows GOARCH=amd64 ./make.bash
cd /usr/local/ngrok
GOOS=windows GOARCH=amd64 make release-client
#同理,這裏的amd64是64位系統,32位改爲386
#應該會在 bin/windows_amd64 目錄下生成ngrok客戶端程序

wKioL1becRXx6gDTAAApnFnavqE058.png

到這裏,編譯就完成了,就能夠將ngrok.exe下載到windows操做系統。windows

啓動步驟:api

一、將ngrok.exe放在D:\ngrok,而且在D:\ngrok編輯配置文件ngrok.cfgxcode

server_addr: "example.com:4443"

trust_host_root_certs: falsebash

2.打開windows控制檯win+r ,進入D:\ngrok,執行
./ngrok -config=ngrok.cfg -log=ngrok.log -subdomain=test 8080

2、編譯Mac客戶端微信

 
 

cd /usr/local/go/src微信開發

GOOS=darwin GOARCH=amd64 ./make.bash

而後回去ngrok目錄,接着編譯:

cd /usr/local/src/ngrok

GOOS=darwin GOARCH=amd64 make release-client

完成後會在 /usr/local/src/ngrok/bin/darwin_amd64/ 下發現 ngrok 文件,將其拷貝到Mac上面,像上面windows

的設置便可使用。


3、注意事項


一、Centos/Linux下源碼安裝golang:

  1. wget https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz

  2. tar -C /usr/local -xzf go1.4.1.linux-amd64.tar.gz

  3. mkdir $HOME/go

  4. echo 'export GOROOT=/usr/local/go' >> ~/.bashrc

  5. echo 'export GOPATH=$HOME/go' >> ~/.bashrc

  6. echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc

  7. source $HOME/.bashrc

二、在步驟GOOS=darwin GOARCH=amd64 make release-client出現錯誤

imports runtime: C source files not allowed when not using cgo or SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_darwin.c mfixalloc.c mgc0.c mheap.c msize.c os_darwin.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c

make: *** [deps] Error 1

解決方法:參考網站 http://stackoverflow.com/questions/27772831/golang-c-source-files-not-allowed-when-not-using-cgo   

https://github.com/golang/go/wiki/InstallFromSource#introduction

Introduction

This is a companion to http://golang.org/doc/install/source providing additional instructions for various operating systems.

Install C tools

On OS X, a C compiler is bundled in the command line tools for Xcode, and you don't need to install the whole Xcode to compile Go. If you have already installed Xcode 4.3+, you can install command line tools from the Components tab of the Downloads preferences panel. In more recent versions of Xcode, you can use xcode-select --install command to install the command line tools without opening Xcode. To verify you have a working compiler, just invoke gcc in a freshly created Terminal window, unless you see the "gcc: command not found" error, you are ready to go.

On Ubuntu/Debian, use sudo apt-get install gcc libc6-dev. If you want to build 32-bit binaries on a 64-bit system you'll also need the libc6-dev-i386 package.

On RedHat/Centos 6, use sudo yum install gcc glibc-devel. If you want to build 32-bit binaries on a 64-bit system you'll need both glibc-devel.i386 and glibc-devel.x86_64 packages.

On Windows, install gcc with TDM-GCC. (Make sure you add its bin subdirectory to your PATH.) Go does not support the Cygwin toolchain.

相關文章
相關標籤/搜索