The error reported by go has been defined multiple times, and an error is reported when using Alibaba Cloud and Amazon Cloud SDK

The content of the error is as follows

/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aws_go/lib/libaws.a(go.o):在函数‘_cgo_topofstack’中:
/usr/lib/go-1.18/src/runtime/asm_amd64.s:1561: `_cgo_topofstack'被多次定义
/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aliyun_go/lib/libaly.a(go.o):/usr/lib/go-1.18/src/runtime/asm_amd64.s:1561:第一次在此定义
/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aws_go/lib/libaws.a(go.o):在函数‘_cgo_panic’中:
/usr/lib/go-1.18/src/runtime/cgo/callbacks.go:45: `_cgo_panic'被多次定义
/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aliyun_go/lib/libaly.a(go.o):/usr/lib/go-1.18/src/runtime/cgo/callbacks.go:45:第一次在此定义
/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aws_go/lib/libaws.a(go.o):在函数‘crosscall2’中:
/usr/lib/go-1.18/src/runtime/cgo/asm_amd64.s:14: `crosscall2'被多次定义
/work/ClipServer.huawei_git/clipServer/src/extrackFrame/src/aliyun_go/lib/libaly.a(go.o):/usr/lib/go-1.18/src/runtime/cgo/asm_amd64.s:14:第一次在此定义
collect2: error: ld returned 1 exit status
CMakeFiles/extrackFrame.dir/build.make:134: recipe for target 'extrackFrame' failed
make[2]: *** [extrackFrame] Error 1
CMakeFiles/Makefile2:74: recipe for target 'CMakeFiles/extrackFrame.dir/all' failed
make[1]: *** [CMakeFiles/extrackFrame.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

analyze

In the project, I used Alibaba Cloud's storage and Amazon's storage, which are divided into domestic and foreign versions. The docking SDK is the Go version SDK, so I packaged Alibaba Cloud's Go SDK into a c static library, and packaged the AWS SDK Create a static library, and then call these two static libraries in the business program, and then report the error as above.

Guess, it is because the SDK of Alibaba Cloud and the SDK of AWS use the same underlying content in go, and after loading two static libraries, a duplicate definition error is caused.

Solution

Based on the above guesses, the Go SDK of Alibaba Cloud and the Go SDK of AWS are packaged in a unified way, and it is a static library everywhere outside, so that there will be no problem of multiple definitions.

After testing, the problem is solved.

insert image description here

Guess you like

Origin blog.csdn.net/bootleader/article/details/129794671