首页 > 解决方案 > 运行 perl 库时的 libz 冲突

问题描述

在 CentOS 7 Linux 上运行 coolname 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

我们的应用程序是用 Perl 开发的,并使用 swig 和 XS 调用 c++ 库。它运行到 Centos。

我们有一个名为 db.pm 的 CORE 包,它实际上是用 c++ 编写的,并使用 XS 来允许 PERL 调用它。

使用 db.pm 我们有一个使用包 GD 打印 png 图像的 perl 代码。所以这段代码加载 db.pm ,获取数据库数据并创建一个图表并尝试打印它。

我们遇到的问题是,在加载 db.pm 时,我们认为 libz 已被访问,而在使用 GD 包时,它调用 libpng,该包也使用 libz。此时,当我们尝试打印图像时,我们有核心转储。

gdb bt 就是这个: 在此处输入图像描述

 my $im = new GD::Image(100,100);

# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);       
my $red = $im->colorAllocate(255,0,0);      
my $blue = $im->colorAllocate(176,196,222);

# make the background transparent and interlaced
$im->transparent($white);
$im->interlaced('true');

# Put a black frame around the picture
$im->filledRectangle(0,0,50,50,'#f2f2f2');





# convert into png data
open my $out, '>', 'heatmap_img.png' or die;
binmode $out;
print $out $img->png;

print 'Success \n';

1;

标签: c++mysqlperlzlib

解决方案


推荐阅读