zengxiaobai commented on issue #305: [Master] go build fail using static library. URL: https://github.com/apache/rocketmq-client-go/issues/305#issuecomment-560293187 I use _go build -ldflags '-extldflags "-static -lstdc++ -lz"'_ , build without stdc++ error but some warnings: ``` [root@kvm-31 rocketxclean]# !go go build -ldflags '-extldflags "-static -lstdc++ -lz"' # rocketmq-filemgr/src/rocketxclean /tmp/go-link-108202940/000028.o: In function `mygetgrouplist': /workdir/go/src/os/user/getgrouplist_unix.go:16: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/go-link-108202940/000027.o: In function `mygetgrgid_r': /workdir/go/src/os/user/cgo_lookup_unix.go:38: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/go-link-108202940/000027.o: In function `mygetgrnam_r': /workdir/go/src/os/user/cgo_lookup_unix.go:43: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/librocketmq.a(UtilAll.cpp.o): In function `rocketmq::UtilAll::getHomeDirectory()': UtilAll.cpp:(.text+0x628): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/go-link-108202940/000027.o: In function `mygetpwnam_r': /workdir/go/src/os/user/cgo_lookup_unix.go:33: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/go-link-108202940/000027.o: In function `mygetpwuid_r': /workdir/go/src/os/user/cgo_lookup_unix.go:28: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /tmp/go-link-108202940/000025.o: In function `_cgo_26061493d47f_C2func_getaddrinfo': /tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/librocketmq.a(SocketUtil.cpp.o): In function `rocketmq::getHostName(sockaddr)': SocketUtil.cpp:(.text+0x114): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/librocketmq.a(evutil.o): In function `evutil_unparse_protoname': evutil.c:(.text+0xefc): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking [root@kvm-31 rocketxclean]# ``` And start failed with ``` untime stack: runtime.throw(0xba5cdd, 0x2a) /home/zwb/go/go1.13/src/runtime/panic.go:774 +0x72 runtime.sigpanic() /home/zwb/go/go1.13/src/runtime/signal_unix.go:378 +0x47c goroutine 1 [syscall]: runtime.cgocall(0x825ac0, 0xc0000fbcf8, 0x4) /home/zwb/go/go1.13/src/runtime/cgocall.go:128 +0x5b fp=0xc0000fbcc8 sp=0xc0000fbc90 pc=0x415fcb github.com/apache/rocketmq-client-go/core._Cfunc_StartPushConsumer(0x7fa28c000940, 0x7fa200000000) _cgo_gotypes.go:1153 +0x49 fp=0xc0000fbcf8 sp=0xc0000fbcc8 pc=0x5363a9 github.com/apache/rocketmq-client-go/core.(*defaultPushConsumer).Start.func1(0xc00006a000, 0xc0000208d0) /home/zwb/go/src/github.com/apache/rocketmq-client-go/core/push_consumer.go:205 +0x5f fp=0xc0000fbd38 sp=0xc0000fbcf8 pc=0x539e3f github.com/apache/rocketmq-client-go/core.(*defaultPushConsumer).Start(0xc00006a000, 0xb8fc58, 0x4) /home/zwb/go/src/github.com/apache/rocketmq-client-go/core/push_consumer.go:205 +0x2b fp=0xc0000fbd58 sp=0xc0000fbd38 pc=0x53830b rocketmq-filemgr/src/rocketmqMy.ConsumeWithPush(0xc0000d0000, 0xb8fc58, 0x4, 0xb8fe76, 0x5, 0xc00002e120, 0x25) /home/zwb/go/src/rocketmq-filemgr/src/rocketmqMy/rocketmqMy.go:89 +0xc0 fp=0xc0000fbde8 sp=0xc0000fbd58 pc=0x8207c0 main.(*rocketmqXclean).RocketMQStart(0xc000100030) /home/zwb/go/src/rocketmq-filemgr/src/rocketxclean/rocketxclean.go:57 +0x1bc fp=0xc0000fbe68 sp=0xc0000fbde8 pc=0x82176c rocketmq-filemgr/src/common.(*ExeCommon).Run(0xc0000d6300, 0xc408e0, 0xc000100030) /home/zwb/go/src/rocketmq-filemgr/src/common/exe_api.go:117 +0xea fp=0xc0000fbe98 sp=0xc0000fbe68 pc=0x817eaa ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
