From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Tue Mar 13 2018 - 16:30:12 CDT

On Tue, Mar 13, 2018 at 3:19 PM, Christian Leitold <
christian.leitold_at_gmail.com> wrote:

> Hello,
>
> I recently wanted to read gzippped LAMMPS trajectories with VMD, and it
> turns out this is possible when the right option is defined. In
> particular, lammpsplugin.c looks for the preprocessor variable _USE_ZLIB.
> This was also mentioned for a similar case in post a few weeks ago:
>
> http://www.ks.uiuc.edu/Research/vmd/mailing_list/vmd-l/28540.html
>
> My question is rather basic: HOW exactly do I activate the preprocessor
> macro in practice? When I just add "#define _USE_ZLIB" it in lammpsplugin.c,
> the compilation fails because apparently it cannot find the zlib functions:
>
> lammpsplugin.c:(.text+0x2e3d): undefined reference to `gzgets'
>
> My guess is that I will need to add a "-lz" linker option at some point,
> but I failed to find out where exactly.
>

​the easiest way is to edit the molfile_plugin​ master makefile, e.g. with
something like this:

cvs diff Makefile
Index: Makefile
===================================================================
RCS file: /vmd/cvsroot/plugins/molfile_plugin/Makefile,v
retrieving revision 1.127
diff -u -r1.127 Makefile
--- Makefile 10 Dec 2016 07:06:40 -0000 1.127
+++ Makefile 13 Mar 2018 21:28:46 -0000
@@ -249,7 +249,7 @@
  $(SHLD) $(LOPTO)${ARCHDIR}/$@ $? $(LDFLAGS)

 lammpsplugin.so: ${ARCHDIR}/lammpsplugin.o
- $(SHLD) $(LOPTO)${ARCHDIR}/$@ $? $(LDFLAGS)
+ $(SHLD) $(LOPTO)${ARCHDIR}/$@ $? $(LDFLAGS) -lz

 mapplugin.so: ${ARCHDIR}/mapplugin.o
  $(SHLD) $(LOPTO)${ARCHDIR}/$@ $? $(LDFLAGS)
@@ -484,7 +484,7 @@
  $(CC) $(CCFLAGS) $(SHLDFLAGS) $(INCDIR) -c $< $(COPTO)$@

 ${ARCHDIR}/lammpsplugin.o: lammpsplugin.c ${PLUGINAPI} hash.c hash.h
inthash.c inthash.h periodic_table.h
- $(CC) $(CCFLAGS) $(SHLDFLAGS) $(INCDIR) -c $< $(COPTO)$@
+ $(CC) $(CCFLAGS) -D_USE_ZLIB $(SHLDFLAGS) $(INCDIR) -c $< $(COPTO)$@

 ${ARCHDIR}/mapplugin.o: mapplugin.C ${PLUGINAPI}
  $(CXX) $(CXXFLAGS) $(SHLDFLAGS) $(INCDIR) -c $< $(COPTO)$@

axel.

>
> Thanks,
> Christian
>

-- 
Dr. Axel Kohlmeyer  akohlmey_at_gmail.com  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.