What do these Go build flags mean? netgo -extldflags “-lm -lstdc++ -static”'

后端 未结 1 1030
南旧
南旧 2021-02-01 22:28

I\'m currently taking a microservice online course where I deploy small go apps to docker containers. The long and ugly command line to build the binaries is this one:



        
相关标签:
1条回答
  • 2021-02-01 22:32

    --tags netgo is used to use go lang network stack

    --ldflags sets the flags that are passed to 'go tool link'

    The value of the args to ldflags is explained in the go tool link help

    -extldflags flags
        Set space-separated flags to pass to the external linker.
    

    In this case the external linker is 'ld' so you can read the man page for it
    Meaning of each of the arguments is:

    -lm enables linking of the standard math library
    -lstdc++ enables linking of the standard c++ library
    -static means do not link against shared libraries
    
    0 讨论(0)
提交回复
热议问题