golang1.9 compile OpenWrt Run program, WINDOW7 under Liteide compile

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Online to see a lot of information found are very outdated, basic is compiled with https://github.com/gomini/go-mips32 .

But go1.9 long-time support MIPS, set the compilation parameters, start build, at this time in the go/pkg will appear linux_mips directory, is the compilation environment, the other same.

    • GOOS is the operating system where your application will run the platform
    • Goarch is the processor architecture in which your application will run the platform.

The valid $GOOS and $GOARCH combined are as follows:

$GOOS $GOARCH Android Arm Darwin386Darwin AMD64 Darwin Arm Darwin arm64 Dragonfly AMD64 FreeBSD386FreeBSD amd64 FreeBSD arm Linux386Linux amd64 linux arm linux arm64 linux PPC64 linux ppc64le Linux MIPS Linux mipsle linux mips64 linux mips64le NetBSD386NetBSD amd64 NetBSD arm OpenBSD386OpenBSD amd64 OpenBSD arm plan9386plan9 amd64 Solaris amd64 Windows386Windows AMD64

1. First connect to the router via putty, look at the Router CPU architecture, I connect wr720n-v3 here, such as, visible that the router CPU is MIPS architecture

Cat/proc/cpuinfo

2.go can set the running schema and system of the compiled program through Goarch and GOOS, so the environment is set at compile time as follows:

I was in window7 under Liteide compile, directly add an environment file (LITEIDE32.1\SHARE\LITEIDE\LITEENV\LINUX32-MIPS.ENV):

Goarch=Mipsgoos=linux

3.golang write the following code, direct build, do not run:

Package Mainimport ("FMT"    " Time") Func main () { for{fmt. Println ("1111") time. Sleep (1*Time . Second) for{time. Sleep (1*Time . Second) fmt. Println ("2222")             Break        }    }}

4. Use WINSCP to put the program file "Openwrttest" into the openwrt system, where it is placed in/TMP, set the file permissions:

777 -r/tmp/openwrttest

5. Run the file and get it done. If you have already entered the TMP directory, use the./openwrttest

/tmp/openwrttest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.