Linking problem: Need to dump linux 64-bit .a file generated by go (6g)

167 views
Skip to first unread message

RickyS

unread,
Jul 10, 2013, 4:12:21 PM7/10/13
to golan...@googlegroups.com
I wrote a package and 'go install' made an archive  '.a' file in ../../pkg/linux_amd64/, which makes perfect sense, as I'm on 64-bit Ubuntu.
I have a main program that imports the package.  One exported function is not found, but the other one generates no complaint.  I need to figure out why.

Both functions in the package start with capital letters and running the linux 'strings' command on the .a file shows both functions exactly the same.  Is there a better tool to display the contents of the archive?
Linux commands 'nm' shows:
nm: __.GOSYMDEF: File format not recognized
nm: __.PKGDEF: File format not recognized
nm: _go_.6: File format not recognized

Running 'go install -v -x' for the package itself shows all 3 .go files are processed by 6g, as they should be.

The package is currently named 'creep', and running 'go run *.go' in the main directory yields the message:
# command-line-arguments
main.main: undefined: creep.LoadJobData
 
Any help at all will be appreciated ­­ -- Thanks.

 RickyS

Kyle Lemons

unread,
Jul 10, 2013, 5:12:01 PM7/10/13
to RickyS, golang-nuts
When you specify files with go run, it compiles all of them.  Use go build, which will process // +build comments, which I suspect might be the issue.

Use `go build -x` and `go install -x` to see the commands that are being run, and `go tool nm` to list symbols.
 
 
Any help at all will be appreciated ­­ -- Thanks.

 RickyS

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

RickyS

unread,
Jul 10, 2013, 6:24:46 PM7/10/13
to golan...@googlegroups.com, RickyS
Your instruction on nm was helpful.  Thanks.  There is still the link error.   There are no +build commands in any of my source code.  There is only one source file for the main program.  Go build isn't supposed to produce output.

There is reference to $WORK/command-line-arguments.a in the output from 'go run -x -v crawl.go' command, which has main.
I'm not using flag or processing command line arguments.  The message is from command-line-arguments, which puzzles me:
# command-line-arguments
main.main: undefined: creep.LoadJobData

The standalone main program is currently called 'crawl'.   The library is called 'creep', it has 3 files.  The directory structure is:
$GOPATH/src/creep/*.go and $GOPATH/src/crawl/crawl.go.  I assume that is permitted.

creep has 4 files altogether: c1_test.go, creep.go, loadtestfile.go, samedomain.go
The four together work well when run as a test.  This is one reason I think it must be a linking problem.
loadtestfile.go has func LoadJobData(), which is causing the error message.
creep.go has func CreepWebSites()

If both were 'undefined', would I see a message about only one of them, the first one it encountered?

 Thanks again, RickyS

RickyS

unread,
Jul 10, 2013, 7:02:16 PM7/10/13
to golan...@googlegroups.com, RickyS
SOLVED!

I ran the builds again using the -x flag and I figured out I had another, older, erroneous version of the  .a file in another pkg directory.  I have three components to my GOPATH.  I remove that old thing and the program links and runs like a champ.

Thanks for all the help.

RickyS
Reply all
Reply to author
Forward
0 new messages