简体   繁体   中英

Why golang binary that compiled in Debian 9 , cant launch in Centos 7?

Compiled an application on Debian 9, when I try to run on CentosOS, I get

./app: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./app)
./app: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./app)
./app: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./app)

ldd ./app show

bash-4.2$ ldd app 
./app: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./app)
./app: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./app)
./app: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./app)
    linux-vdso.so.1 =>  (0x00007fff24901000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f45a97ff000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f45a94f8000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f45a91f5000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f45a8fdf000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f45a8c12000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f45a9a25000)

Your program is likely using cgo implicitly and generating an executable that depends on the C++ ABI versions of the host machine that is doing the compiling (Debian 9). Unfortunately, it appears that your execution target (CentOS 7) has an incompatible ABI.

You can verify by compiling with cgo disabled, eg:

$ CGO_ENABLED=0 go build -o ./app ./app-folder

That command will likely fail, so your options are likely to:

  1. refactor the parts of your go code which rely on cgo to use native go alternatives, OR...
  2. compile on a machine which has a compatible ABI as your execution target platform.

See also Application binary interface (ABI) and GCC ABI Compatibility .

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