我正在尝试构建代码。当我尝试执行以下操作时:go build
我收到以下错误:
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/Versions/A/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/Versions/A/IOKit are out of sync. Falling back to library file for linking.
duplicate symbol _FetchPEMRootsCTX509_MountainLion in:
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000033.o
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000036.o
duplicate symbol _FetchPEMRootsCTX509 in:
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000033.o
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000036.o
duplicate symbol _useOldCodeCTX509 in:
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000033.o
/var/folders/v8/94mqr56n2yqd9pcj8rd21cyr0000gp/T/go-link-418396971/000036.o
ld: 3 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
尝试搜索此问题,但找不到任何确定性的信息。有人可以帮助我吗?
go run
中运行良好,因此运行正常。go build -v
,并且输出是相同的。答案 0 :(得分:0)
出现此错误的原因之一是因为您正在运行同一个程序包的功能以及程序包名称。示例:
package server
...
server.functionOfSamePackage()
因此将其更新为:
package server
...
functionOfSamePackage()