Adr*_*ebs 13 command-line compilation go
我目前正在上一个微服务在线课程,我将小型应用程序部署到docker容器.构建二进制文件的漫长而丑陋的命令行是这样的:
go build --tags netgo --ldflags '-extldflags "-lm -lstdc++ -static"'
Run Code Online (Sandbox Code Playgroud)
到现在为止我只是用来go install编译我的应用程序.
任何人都可以向我解释这个命令吗?
--tags netgo用于使用go lang网络堆栈
--ldflags 设置传递给“转到工具链接”的标志
go工具链接帮助中解释了args到ldflags的值
-extldflags flags
Set space-separated flags to pass to the external linker.
Run Code Online (Sandbox Code Playgroud)
在这种情况下,外部链接器为“ ld”,因此您可以为其 阅读手册页
。每个参数的含义是:
-lm enables linking of the standard math library
-lstdc++ enables linking of the standard c++ library
-static means do not link against shared libraries
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3241 次 |
| 最近记录: |