Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile on Mountain Lion #15

Open
dawe opened this issue Oct 17, 2012 · 1 comment
Open

Doesn't compile on Mountain Lion #15

dawe opened this issue Oct 17, 2012 · 1 comment

Comments

@dawe
Copy link

dawe commented Oct 17, 2012

samtools doesn't compile on Mountain Lion. bam_qa.c produces this error

bam_qa.c: In function 'main_qa':
bam_qa.c:88: warning: implicit declaration of function 'getopt'
bam_qa.c:92: error: 'optarg' undeclared (first use in this function)
bam_qa.c:92: error: (Each undeclared identifier is reported only once
bam_qa.c:92: error: for each function it appears in.)
bam_qa.c:96: error: 'optind' undeclared (first use in this function)
make[1]: *** [bam_qa.o] Error 1
make: *** [all-recur] Error 1

This is easily solved with this patch

diff --git a/bam_qa.c b/bam_qa.c
index ef2ea85..16813cb 100644
--- a/bam_qa.c
+++ b/bam_qa.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <unistd.h>
 #include "radix.h"
 #include "sam.h"

in addition, linking produces this error:

clang -g -Wall -O2 -o samtools bam_tview.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 bam2bcf.o bam2bcf_indel.o errmod.o sample.o cut_target.o phase.o bam2depth.o bam_qa.o padding.o  libbam.a -Lbcftools -lbcf  -lcurses  -lm -lz
Undefined symbols for architecture x86_64:
  "___ks_insertsort_heap", referenced from:
      _ks_combsort_heap in libbam.a(bam_sort.o)
      _ks_introsort_heap in libbam.a(bam_sort.o)
  "___ks_insertsort_sort", referenced from:
      _ks_combsort_sort in libbam.a(bam_sort.o)
      _ks_introsort_sort in libbam.a(bam_sort.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The latter error is not raised if gcc is used, but clang is the default compiler for OSX 10.8 (and latest FreeBSD too). One simple (and correct) solution is to make the inlined function static.


diff --git a/ksort.h b/ksort.h
index fa850ab..f8d8c4c 100644
--- a/ksort.h
+++ b/ksort.h
@@ -141,7 +141,7 @@ typedef struct {
            tmp = *l; *l = l[i]; l[i] = tmp; ks_heapadjust_##name(0, i, l); \
        }                                                               \
    }                                                                   \
-   inline void __ks_insertsort_##name(type_t *s, type_t *t)            \
+   static inline void __ks_insertsort_##name(type_t *s, type_t *t)         \
    {                                                                   \
        type_t *i, *j, swap_tmp;                                        \
        for (i = s + 1; i < t; ++i)                                     \
@Buttonwood
Copy link

Great! It works!

mys721tx added a commit to mys721tx/crisp that referenced this issue Feb 15, 2020
The distributed objective file will leads to linker errors on some
platform. This commit applies a upstream patch (lh3/samtools#15) to
allow compiling samtools from source. Copying `CRISP` to the base
directory will cause error on case-insensitive file systems and thus is
disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants