# Help Building Tophat 2.0.11



## aorchid (May 30, 2014)

Hello,

I am trying to build tophat 2.0.11 (http://tophat.cbcb.umd.edu) on FreeBSD 10.0-RELEASE-p3. It can build on Mac OS using clang, so in theory on FreeBSD? There is a patch I found for clang builds on Mac OS 10.9 (can be seen here https://07110005642076687011.google...vPHjGVOcEaywsVQvz6XRLmaxYxJ57iwWpzQ68hqfPmPpM). Despite this patch the `make` eventually fails and I am entirely lost on how to proceed, if it is even possible. 

Here is the output of configure and I have uploaded the entire configure.log. 

```
-- tophat 2.0.11 Configuration Results --
  C++ compiler:        c++ -Wall -Wno-strict-aliasing -g -gdwarf-2 -Wuninitialized  -O3  -DNDEBUG -pthread -I/usr/local/include -I/fitz/home/aorchid/bin/include -I./SeqAn-1.3
  Linker flags:
  GCC version:         FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
  Host System type:    x86_64-unknown-freebsd10.0
  Install prefix:      /fitz/home/aorchid/bin
  Install eprefix:     ${prefix}
```

This is the failure notice I get during make:


```
...
if c++ -DHAVE_CONFIG_H -I. -I. -I..      -Wall -Wno-strict-aliasing -g -gdwarf-2 -Wuninitialized  -O3  -DNDEBUG -pthread -I/usr/local/include -I/fitz/home/aorchid/bin/include -I./SeqAn-1.3 -MT bam_merge.o -MD -MP -MF ".deps/bam_merge.Tpo" -c -o bam_merge.o bam_merge.cpp;  then mv -f ".deps/bam_merge.Tpo" ".deps/bam_merge.Po"; else rm -f ".deps/bam_merge.Tpo"; exit 1; fi
bam_merge.cpp:28:12: error: use of undeclared identifier 'optind'
  if (argc-optind<3) {
           ^
bam_merge.cpp:34:17: error: use of undeclared identifier 'optind'
  outfname=argv[optind];
                ^
bam_merge.cpp:36:14: error: use of undeclared identifier 'optind'
  for (int i=optind+1;i<argc;i++)
             ^
3 errors generated.
*** Error code 1

Stop.
make[2]: stopped in /fitz/home/aorchid/downloads/tophat-2.0.11/src
*** Error code 1
```

Suggestions and help would be greatly appreciated.
Thanks.


----------



## aorchid (Jul 3, 2014)

Just to post a reply so that others can get Tophat to build on FreeBSD. The patch below works:


```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- src/common.h.orig   2014-07-02 12:29:14.867710000 -0500
+++ src/common.h        2014-07-02 12:29:29.429711325 -0500
@@ -9,6 +9,7 @@
  *
  */
 #include <stdint.h>
+#include <unistd.h>
 #include <cassert>
 #include <cstring>
 #include <cstdlib>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```


----------

