[Bioperl-l] building samtools/Bio::DB::Sam on cygwin

Mark A. Jensen maj at fortinbras.us
Mon Nov 23 17:58:46 UTC 2009


Hi All--

I've had some hard-won success installing samtools and Lincoln's
Bio::DB::Sam under cygwin; thought some on the list would be able to
use my notes. (Yes, Jason, I'm working on Bio::Tools::Run::BWA...)


(To get the current samtools, ping
http://sourceforge.net/projects/samtools/files/samtools/0.1.7/samtools-0.1.7a.tar.bz2/download
)

* Getting samtools to make from scratch in cygwin

The following diff details the changes to the samtools Makefile I made
by hand. The key points are

-D_WIN32

and the additional variable LFLAGS and its interpolations. To get the
linker to see

libgcc libstdc++

I needed to add symlinks from /lib to the correct files in
/lib/gcc/i386-pc-cygwin/4.3.2/. Your gcc version may differ.


--- ../old/samtools-0.1.7a/Makefile 2009-11-16 10:13:43.000000000 -0500
+++ Makefile 2009-11-23 12:14:18.529000000 -0500
@@ -1,16 +1,18 @@
 CC=   gcc
 CFLAGS=  -g -Wall -O2 #-m64 #-arch ppc
-DFLAGS=  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -D_CURSES_LIB=1
+LFLAGS=         -lws2_32 -lgcc -lcygwin -lbz2 -lz -lstdc++
+DFLAGS=  -D_WIN32 -D_FILE_OFFSET_BITS=64 -D_CURSES_LIB=1
 LOBJS=  bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \
    bam_pileup.o bam_lpileup.o bam_md.o glf.o razf.o faidx.o knetfile.o \
    bam_sort.o sam_header.o
 AOBJS=  bam_tview.o bam_maqcns.o bam_plcmd.o sam_view.o \
    bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o \
    bamtk.o kaln.o

@@ -36,13 +38,13 @@
   $(AR) -cru $@ $(LOBJS)
 
 samtools:lib $(AOBJS)
-  $(CC) $(CFLAGS) -o $@ $(AOBJS) -lm $(LIBPATH) $(LIBCURSES) -lz -L. -lbam
+  $(CC) $(CFLAGS) -o $@ $(AOBJS) -Xlinker --enable-auto-import -lm $(LIBPATH) $(LIBCURSES) -lz -L. -lbam $(LFLAGS)
 
 razip:razip.o razf.o knetfile.o
-  $(CC) $(CFLAGS) -o $@ razf.o razip.o knetfile.o -lz
+  $(CC) $(CFLAGS) -o $@ razf.o razip.o knetfile.o -lz -lm -lws2_32
 
 bgzip:bgzip.o bgzf.o
-  $(CC) $(CFLAGS) -o $@ bgzf.o bgzip.o -lz
+  $(CC) $(CFLAGS) -o $@ bgzf.o bgzip.o -lz -lm -lws2_32
 
 razip.o:razf.h
 bam.o:bam.h razf.h bam_endian.h kstring.h sam_header.h

* Getting Bio::DB::Sam to compile and install

Bio::DB::Sam requires not the samtools.exe, but the bam library
created during the samtools build, as well as all the samtools header
files. Create a symlink in /lib to libbam.a in the build directory (or
copy libbam.a up to /lib), and create symlinks or copy *.h into
/usr/include. Then in cygwin bash shell

$ cpan
cpan> install Bio::DB::Sam

should fly. 

Hope someone finds this useful. These mods led me to a successful
Bio::DB::Sam install--have not yet checked original code based on
Bio::DB::Sam. If they don't work for you, reply to the list.

cheers, 
MAJ 




More information about the Bioperl-l mailing list