如何在 Intel Pin 工具中使用(编译)zlib(gzip 函数)压缩库?

How do I use (compile) zlib (gzip functions) compression library within Intel Pin tool?

我在 ubuntu 20.04 上安装了 libz-dev。我在 pin/source/tools/SimpleExamples/icount.cpp 中添加了以下行:

#include <zlib.h>

在 main() 中:

gzFile gp;
gp = gzopen("compressed_log_file", "ab");
gzbuffer(gp, 100000);

我的 linking 生成文件构建规则是:

$(OBJDIR)icount$(PINTOOL_SUFFIX): $(OBJDIR)icount$(OBJ_SUFFIX)
    $(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $< $(TOOL_LPATHS) $(TOOL_LIBS) -lz

它跟在 Intel Pin User Guide 之后,除了我添加的 -lz 标志。

我可以毫无错误地制作,但是当我 运行 pin 工具时,我得到这个错误:

E: Unable to load /pin/source/tools/SimpleExamples/obj-intel64/icount.so: dlopen failed: library "libz.so.1" not found

我的执行命令是:

../../../../pin -t icount.so -- ls
  1. 我 link 正确吗?
  2. 我应该尝试 link 静态而不是使用 dlopen 吗?

我无法直接编译,所以我最终只使用了 pin 工具,然后重定向输出(来自 stderr)并将其通过管道传输到 gzip 命令行实用程序中。

./path_to_pin/pin -t icount.so -- ls 3>&2 2>&1 1>&3 | gzip -c > my_compression_output.txt