为了账号安全,请及时绑定邮箱和手机立即绑定

这些 Go 构建标志是什么意思?netgo -extldflag

这些 Go 构建标志是什么意思?netgo -extldflag

Go
蝴蝶刀刀 2022-01-17 10:49:54
我目前正在学习微服务在线课程,我将小型 Go 应用程序部署到 docker 容器。用于构建二进制文件的长而丑陋的命令行是这样的:go build --tags netgo --ldflags '-extldflags "-lm -lstdc++ -static"'到目前为止,我只是用来go install编译我的 go 应用程序。谁能向我解释这个命令?
查看完整描述

1 回答

?
慕标5832272

TA贡献1966条经验 获得超4个赞

--tags netgo 用于使用 go lang 网络栈


--ldflags设置传递给“go tool link”的标志


args 到 ldflags 的值在go tool 链接帮助中有说明


-extldflags flags

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

在这种情况下,外部链接器是“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


查看完整回答
反对 回复 2022-01-17
  • 1 回答
  • 0 关注
  • 407 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信