"multiple roots" error with 'go install buildmode=shared'

557 views
Skip to first unread message

aar...@arista.com

unread,
Aug 12, 2015, 8:54:31 PM8/12/15
to golang-nuts
Hello,

I am having trouble trying to build a shared library of my code using go1.5 rc1.

> go install -buildmode=shared ./...
multiple roots /home/aaronb/go/pkg/linux_amd64_dynlink & /home/aaronb/gosrc/pkg/linux_amd64_dynlink

'go build -buildmode=shared ./...' works just fine.

This fails in the same way using the HEAD of the master branch of the go repository.

I do have multiple versions of go installed on this machine since I am trying out go1.5. I switch between them by modifying PATH so that my desired go binary comes up first.

Here is the output of go env when I am using my compiled version the head of the go repostitory:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/aaronb/go"
GORACE=""
GOROOT="/home/aaronb/gosrc"
GOTOOLDIR="/home/aaronb/gosrc/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Any help would be appreciated.

Thanks,
Aaron

Ian Lance Taylor

unread,
Aug 12, 2015, 9:24:08 PM8/12/15
to aar...@arista.com, golang-nuts
Yes, it's less than ideal, and please open an issue about this if
there isn't one already.

The problem is that ./... in GOPATH will need to link in the standard
libraries under GOROOT, and go install doesn't know where to install
the result.

The solution is

go install -buildmode=shared std
go install -buildmode=shared -linkshared ./...

You will get one shared library for the standard library, and one for
your code.

Ian

aar...@arista.com

unread,
Aug 13, 2015, 12:59:16 PM8/13/15
to golang-nuts, aar...@arista.com
Thanks for your help.

Reply all
Reply to author
Forward
0 new messages