go tool link

该命令链接Go的归档文件比如静态库,以及链接其所有依赖,生成一个可执行文件(含main package)。

go tool link [flags] main.a
Flags:

    -B note
        Add an ELF_NT_GNU_BUILD_ID note when using ELF.
        The value should start with 0x and be an even number of hex digits.
    -D address
        Set data segment address.
    -E entry
        Set entry symbol name.
    -H type
        Set executable format type.
        The default format is inferred from GOOS and GOARCH.
        On Windows, -H windowsgui writes a "GUI binary" instead of a "console binary."
    -I interpreter
        Set the ELF dynamic linker to use.
    -L dir1 -L dir2
        Search for imported packages in dir1, dir2, etc,
        after consulting $GOROOT/pkg/$GOOS_$GOARCH.
    -R quantum
        Set address rounding quantum.
    -T address
        Set text segment address.
    -V
        Print linker version and exit.

go tool compile -o calc.o -I pkg/linux_amd64 src/calc/calc.go
go tool link -o bin/calc -L pkg/linux_amd64 calc.o

参考:

http://cache.baiducontent.com/

最后编辑: kuteng  文档更新时间: 2022-07-29 14:34   作者:kuteng