Reputation: 2291
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?)
Upvotes: 1
Views: 622
Reputation: 43899
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).
Upvotes: 1