简体   繁体   English

为什么在Debian 9中编译的golang二进制文件不能在Centos 7中启动?

[英]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 当我尝试在CentosOS上运行时,在Debian 9上编译了一个应用程序,

./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 ldd ./app节目

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). 您的程序可能隐式使用cgo并生成一个可执行文件,该可执行文件取决于正在进行编译的主机的C ++ ABI版本 (Debian 9)。 Unfortunately, it appears that your execution target (CentOS 7) has an incompatible ABI. 不幸的是,您的执行目标(CentOS 7)似乎具有不兼容的ABI。

You can verify by compiling with cgo disabled, eg: 您可以通过禁用cgo进行编译来验证,例如:

$ 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... 重构依赖cgo来使用本机go替代方案的go代码部分,或者...
  2. compile on a machine which has a compatible ABI as your execution target platform. 在具有兼容ABI作为执行目标平台的机器上进行编译。

See also Application binary interface (ABI) and GCC ABI Compatibility . 另请参阅应用程序二进制接口(ABI)GCC ABI兼容性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从编译的二进制文件中获取 golang 版本 - Get golang version from compiled binary 如何检查是否使用--ldflags =“ - s -w”编译golang二进制文件 - how to check whether golang binary is compiled with --ldflags=“-s -w” 为什么我不能列出 golang package 版本 - why i cant list the golang package version Docker golang 应用程序的临时图像找不到二进制“没有这样的文件或目录” - Docker scratch image for golang app cant find binary “no such file or directory” 有没有一种方法可以在不需要任何特殊设置的情况下从另一个二进制文件执行已编译的 golang 二进制文件中的函数? - Is there a way to execute functions in a compiled golang binary from another binary without needing any special setup? 分割错误Debian 8 Golang - Segmentation fault debian 8 golang net / http.Get()中的VPN连接时,Golang交叉编译的OSX二进制文件挂起 - Golang cross-compiled OSX binary hangs while VPN'ed in net/http.Get() 如果我的golang应用程序编译时没有错误并且不返回错误,为什么我不返回Postgres记录? - Why is my golang app returning no Postgres records if compiled without error and returns no errors? 在已编译的二进制文件上启用 -race - Enable -race on compiled binary Heroku上的Golang二进制文件 - Golang binary on Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM