go 项目编译失败

ubuntu@dongyang-K46CB:~/sunteng/src/dsp_masky/bin/bid$ go build server.go
# github.com/coreos/go-etcd/etcd
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:99:6: r.EncodeArrayStart undefined (type codec.encDriver has no field or method EncodeArrayStart)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:107:6: r.EncodeMapStart undefined (type codec.encDriver has no field or method EncodeMapStart)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:111:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:119:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:121:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:130:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:142:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:144:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:157:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:170:6: z.EncSendContainerState undefined (type codec.genHelperEncoder has no field or method EncSendContainerState)
/home/ubuntu/go/src/github.com/coreos/go-etcd/etcd/response.generated.go:170:6: too many errors
# dsp_masky/library/db/shm_index
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_GetLastError’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:52:对‘GetLastError’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_GetVersion’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:69:对‘GetVersion’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashDestroy’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:99:对‘HashDestroy’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashGet’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:119:对‘HashGet’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashHeadToString’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:136:对‘HashHeadToString’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashToString’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:191:对‘HashToString’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_NewHash’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:210:对‘NewHash’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_FreeHash’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:37:对‘FreeHash’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashClean’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:83:对‘HashClean’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashInit’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:150:对‘HashInit’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashRebuild’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:162:对‘HashRebuild’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_HashSet’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:176:对‘HashSet’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/hash.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_SetVersion’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:225:对‘SetVersion’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexError’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:64:对‘IndexError’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexGetTop’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:82:对‘IndexGetTop’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexInit’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:100:对‘IndexInit’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexResize’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:119:对‘IndexResize’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexUpdate’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:151:对‘IndexUpdate’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_NewIndex’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:171:对‘NewIndex’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_NextHash’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:188:对‘NextHash’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_TopHash’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:205:对‘TopHash’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_FreeIndex’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:37:对‘FreeIndex’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexClear’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:49:对‘IndexClear’未定义的引用
/tmp/go-build128556831/dsp_masky/library/db/shm_index/_obj/index.cgo2.o:在函数‘_cgo_74c72ce7a376_Cfunc_IndexSetTop’中:
/tmp/go-build/dsp_masky/library/db/shm_index/_obj/cgo-gcc-prolog:135:对‘IndexSetTop’未定义的引用
collect2: error: ld returned 1 exit status

第一部分错误是github.com/coreos/go-etcd/包版本不对,不能clone master,新版本有较大变动,要clone release-0.4版本

使用git克隆指定分支的代码

第二部分错误是因为gcc编译失败,因为没有写权限,到gcc文件目录下make就可以看到报错,用root用户先将c++文件编译好再编译go文件即可

原文地址:https://www.cnblogs.com/cdyboke/p/7879629.html