Go? Go! (1) Compilation and Installation

Source: Internet
Author: User

Installation Method

For the installation method, see urlhttp: // golang.org/doc/install/gccgo

  1. Get the code documentation or something on SVN:svn://gcc.gnu.org/svn/gcc/branches/gccgo
  2. Go to the folder and run the configure command. Note that the latest GCC installation requires some compilation dependencies, for the installation of these compilation dependencies, refer to another article by the author that supports the installation of C ++ 0x GCC.
    Some compilation options are required for configure execution. The specific meanings of these options can be obtained through -- help. The parameters used by the author are:

    ./configure --prefix=$HOME --enable-languages=c,c++,go --with-arch-32=i586

    Then make & make install
    We recommend that you use make in the background. This is definitely a long wait...

  3. Then let's get it done. Write a simple hello World:
    # Helloword. Go package main import "FMT" func main () {FMT. println ("Hello, go world ")}
  4. Then compile and link
    $ gccgo -c helloWord.go          $ gccgo -o hello helloWord.o  
  5. Run the hello file. OK. Welcome to go !~

A problem occurred when installing the program according to the above method. The executable program of go is not installed, so it cannot be a good go install...

So I tried again:

  1. Go to the libgo folder and run./configure -- prefix = $ home -- enable-sjlj-exceptions -- enable-multilib = No -- without-libffi.
  2. Then modify CC in makefile to gccgo (the premise is that the above installation is OK, that is, the gccgo installation is successful) and execute make. Then wait, because-O2 is optimized, and the compilation speed is a little slow.
  3. Make install
Then, the tragedy found that the go command is still unavailable... Can only be compiled with gccgo... Go to the Internet to find another document, the above need to use Hg clone-u release https://go.googlecode.com/hg/ go this unreliable, brother again to find, you can use the following path to download: Pull. Then it's easy. Set the environment variable and go to sh./All. Sh in SRC to clean up the world ~ P.s. Later looked for information on the Internet and found that gccgo and go are both usable...
What makes me feel like this? So use both of them...

Some language features of go will be updated in the future.

Related Article

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.