简体   繁体   中英

Find which dependency uses cgo

I'm getting the following error when I compile my Go binary locally and then run it on my docker container:

my-server: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by my-server)
my-server: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by my-server)

Everything works fine if I set CGO_ENABLED=0 when compiling. None of my code uses glibc, so I'm just curious which of my dependencies is pulling it in. Is there any way to query which dependency requires this?

which of my dependencies is pulling it in

Running LD_DEBUG=files my-server |& grep 'needed by' will produce lines similar to:

   2310307:     file=libtinfo.so.6 [0];  needed by ... [0]
   2310307:     file=libc.so.6 [0];  needed by ... [0]

which should answer your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM