doulupian8725 2013-09-22 03:26
浏览 23
已采纳

如何从Go库中获取对象构建信息?

I'm trying to build a Go program where I have a required library on my system in binary form. However, go build fails with

object is [linux amd64 go1.1.1 X:none] expected [linux amd64 go1.1.2 X:none]

I see what the immediate problem is: the static library was built with an older version of Go. How can I read that information from the .a file directly? (I can see it with strings library.a | grep '^go object', but is there something that's meant to output the build string? (And, what is that string properly called?)

  • 写回答

1条回答 默认 最新

  • dongtiandexue123456 2013-09-22 15:18
    关注

    The .a files the Go compiler produces are managed using the pack tool. The metadata used to link the package is found in the __.PKGDEF member of the archive.

    You can extract this file from an archive to stdout with:

    go tool pack p path/to/package.a __.PKGDEF
    

    It starts with the build signature you're after, so you could either take the first line or grep for ^go object as you were with the output of strings (this should be a bit more reliable, in case that text shows up as a constant in the program code).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog