On 1 Dec 2015, at 12:20, hgong <[email protected]> wrote:
> I am new to the samtools. I install samtools 1.2 as it's directed and it
> succeeds. when I try compile your example of samtools C :
>
> http://samtools.sourceforge.net/sam-exam.shtml
This is an old web page containing a program demonstrating using the old
samtools API. For newcomers writing new code, we would recommend using the
HTSlib API in htslib-1.x/htslib/*.h as that is more flexible and better
supported these days. There ought to be more example code (and that page needs
updating!) but the smaller samtools subcommands are a good starting point.
Having said that, these problems can be solved without too much trouble:
> it send out the the following error. Can you help me ?
>
> test_sam_h.c:(.text+0x124): undefined reference to `samopen'
> test_sam_h.c:(.text+0x182): undefined reference to `sampileup'
> test_sam_h.c:(.text+0x19f): undefined reference to `hts_idx_load'
[snip]
The example program uses the old samtools API headers (e.g. "sam.h") and to get
this far, you've clearly used enough gcc -I options pointing at samtools-1.2
and htslib-1.2.1 to get it to find the headers and compile. As well as the
legacy headers like sam.h, samtools currently provides a legacy libbam.a
containing the old API functions.
So you need to add -lbam -lhts -lz to your compilation command, and enough -L
paths that your command can find libbam.a and libhts.* (similar to the -I paths
helping it find the samtools and htslib header files).
But it would be good to look at that example code and compare it with (the
non-argument handling parts of) samtools-1.2/bam2depth.c, which is similar code
using the HTSlib API directly, and write your code using the HTSlib API
directly too.
Cheers,
John
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help