I have libz-dev installed on ubuntu 20.04. I added the following lines in pin/source/tools/SimpleExamples/icount.cpp :
#include <zlib.h>
and in main():
gzFile gp;
gp = gzopen("compressed_log_file", "ab");
gzbuffer(gp, 100000);
My makefile build rule for linking is:
$(OBJDIR)icount$(PINTOOL_SUFFIX): $(OBJDIR)icount$(OBJ_SUFFIX)
$(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $< $(TOOL_LPATHS) $(TOOL_LIBS) -lz
which follows the Intel Pin User Guide except for the -lz flag I added.
I can make with no errors, but when I run the pin tool, I get this error:
E: Unable to load /pin/source/tools/SimpleExamples/obj-intel64/icount.so: dlopen failed: library "libz.so.1" not found
My execution command is:
../../../../pin -t icount.so -- ls
I wasn't able to compile directly, so I ended up just using the pin tool and then redirecting the output (from stderr) and piping it into the gzip command line utility.
./path_to_pin/pin -t icount.so -- ls 3>&2 2>&1 1>&3 | gzip -c > my_compression_output.txt