NOTE: I write these examples exactly the way they worked for me. No guarantees whatsoever, etc, etc.

NCBI released a new version of blast: 2.2.29+ on January 6 (the newest versions of blast are always available at ftp://ftp.ncbi.nih.gov/blast/executables/LATEST/). Given my obsession with having the latest versions of whatever in my machines, and to compile them in my machines, I’ve got the source file, and made a few attempts at compiling it. Here’s the notes on the experience.

First and foremost, I’ll refer you to previous blast compilation posts. In those I said that blast would not compile with the compilers provided by Apple, such as Xcode and the command line tools. This is still true for blast 2.2.29+ (I did try). Therefore, I set the environment to use gcc-4 as installed with fink (I use “tail” commands to avoid showing too much output, but you shouldn’t need them in order for this to work. Commands follow a “%” sign. Everything else is output produced by the commands. Click on the terminal titles to expand the terminals and see what’s going on):

% mkdir BUILD
% cd BUILD
% tar zxvf ../ncbi-blast-2.2.29+-src.tar.gz | tail -5
% cd ncbi-blast-2.2.29+-src/c++/
% setenv CC "/sw/bin/gcc-4"
% setenv CXX "/sw/bin/g++-4"
% setenv CFLAGS "-O3"
% setenv CXXFLAGS "-O3"

Remember that I use the tcsh. Under bash, the setenv commands should be of the “export CC /sw/bin/gcc-4” instead. After that I ran the following configure command as inspired by the instructions at NCBI:

%  ./configure --without-debug --with-strip --with-mt --with-build-root=ReleaseMT --with-static --with-static-exe --prefix=/usr/local/ncbi |& tail -5
To build everything:  cd /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/build && make all_r
or simply run make in the current directory


Note that I used the exact command suggested by NCBI, plus “–with-static –with-static-exe –prefix=/usr/local/ncbi”, which should install the software under /usr/local/ncbi and produce executables with integrated libraries (hopefully. I don’t know if this truly happens).

In any event, if I try and compile after the configure command this is what I get (if you use the “tail” command be prepared to wait quite a while before you see any output):

% make -j 6 |& tail -15
/Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/scripts/common/impl/favor-static: warning: unrecognized platform; not interfering
Undefined symbols for architecture x86_64:
  "isalpha(int)", referenced from:
      ncbi::CHTMLHelper::StripSpecialChars(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libxhtml-static.a(htmlhelper.o)
  "isdigit(int)", referenced from:
      ncbi::CHTMLHelper::StripSpecialChars(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libxhtml-static.a(htmlhelper.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[4]: *** [blastp] Error 1
FAILED: src/app/blast/Makefile.blastp.app
/bin/rm -f blastp .blastp.stamp
make[3]: *** [all.nonusr] Error 2
make[2]: *** [all_r.real] Error 5
make[1]: *** [all_r.real] Error 5
make: *** [all] Error 2

Woa! Not too good. I went to many web sites where an “Undefined symbols for architecture x86_64” problem was mentioned. But all of them referred to using mavericks and the xcode/command line tools from Apple. I was using gcc48 instead. In any event, I tried several things. In the end, this is what solved the problem: I started fresh by first erasing the whole “ncbi-blast-2.2.29+-src” directory and its contents. I extracted the files again (tar command above), up to the “./configure” command. Then, I went to the “ReleaseMT/build/” directory and edited the “Makefile.mk” file and erased every instance of ‘-std=’ options (be amazed at the magical “perl” command!):

% cd ReleaseMT/build/
% perl -i.bak -pe 's{\s+\-std=\S+}{}' Makefile.mk
% diff Makefile.mk Makefile.mk.bak
< CONF_CC     = /sw/bin/gcc-4 -fgnu89-inline
< CONF_CXX    = /sw/bin/g++-4
< CONF_CPP    = /sw/bin/gcc-4 -fgnu89-inline -E
< CONF_CXXCPP = /sw/bin/g++-4 -E
> CONF_CC     = /sw/bin/gcc-4  -std=gnu11 -fgnu89-inline
> CONF_CXX    = /sw/bin/g++-4  -std=gnu++11
> CONF_CPP    = /sw/bin/gcc-4  -std=gnu11 -fgnu89-inline -E
> CONF_CXXCPP = /sw/bin/g++-4  -std=gnu++11 -E
< LINK_DLL      = /sw/bin/gcc-4 -fgnu89-inline -m64 -nostartfiles -Wl,-dynamic -Wl,-dylib -Wl,-install_name,/usr/local/ncbi/lib/$(XDLL) -o
< LINK_LOADABLE = /sw/bin/gcc-4 -fgnu89-inline -m64 -nostartfiles -Wl,-dynamic -Wl,-bundle -Wl,-read_only_relocs,warning -lbundle1.o -o
> LINK_DLL      = /sw/bin/gcc-4  -std=gnu11 -fgnu89-inline -m64 -nostartfiles -Wl,-dynamic -Wl,-dylib -Wl,-install_name,/usr/local/ncbi/lib/$(XDLL) -o
> LINK_LOADABLE = /sw/bin/gcc-4  -std=gnu11 -fgnu89-inline -m64 -nostartfiles -Wl,-dynamic -Wl,-bundle -Wl,-read_only_relocs,warning -lbundle1.o -o

Then I went back and ran make (if you use the “tail” command be prepared to wait much more, because, since it all compiles, it takes much longer than the previous make):

% cd ../../
% make -j 6 |& tail -15
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C splign -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C hfilter -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C annotwriter -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C compart -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C streamtest -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C lds2_indexer -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C discrep_report -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C biosample_chk -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C gap_stats -j --jobserver-fds=3,4 all_r  ||  exit 5
NCBI_BUT_EXPENDABLE=' (but expendable)'  /Applications/Xcode.app/Contents/Developer/usr/bin/make -C split_cache -j --jobserver-fds=3,4 all_r  ||  exit 5
NCBI_BUT_EXPENDABLE=' (but expendable)'  /Applications/Xcode.app/Contents/Developer/usr/bin/make -C wig2table -j --jobserver-fds=3,4 all_r  ||  exit 5
NCBI_BUT_EXPENDABLE=' (but expendable)'  /Applications/Xcode.app/Contents/Developer/usr/bin/make -C netcache -j --jobserver-fds=3,4 all_r  ||  exit 5
NCBI_BUT_EXPENDABLE=' (but expendable)'  /Applications/Xcode.app/Contents/Developer/usr/bin/make -C rmblastn -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C sample -j --jobserver-fds=3,4 all_r  ||  exit 5
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C internal -j --jobserver-fds=3,4 all_r  ||  exit 5

Eureka! I installed the resulting programs and everything went well from that moment on:

% sudo make install |& tail -15
/bin/rm -rf /usr/local/ncbi/include/ncbi-tools++
/sw/bin/ginstall -c -d /usr/local/ncbi/bin /usr/local/ncbi/lib /usr/local/ncbi/include/ncbi-tools++
/sw/bin/ginstall -c /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/bin/* /usr/local/ncbi/bin
/sw/bin/ginstall -c -m 644 /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/lib/*.* /usr/local/ncbi/lib
if test -d /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/lib/ncbi; then \
	    cp -pPR /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/lib/ncbi /usr/local/ncbi/lib/; \
rm -f /usr/local/ncbi/lib/lib*-static.a
cd /usr/local/ncbi/lib  && \
	    for x in *.a; do ln -s "$x" "`basename \"$x\" .a`-static.a"; done
cd /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/include && find * -name CVS -prune -o -print |\
            cpio -pd /usr/local/ncbi/include/ncbi-tools++
47770 blocks
/sw/bin/ginstall -c -m 644 /Users/gmh/BUILD/ncbi-blast-2.2.29+-src/c++/ReleaseMT/inc/* /usr/local/ncbi/include/ncbi-tools++
% cd
% which blastp
% file `which blastp`
/usr/local/ncbi/bin/blastp: Mach-O 64-bit executable x86_64
% blastp -h
  blastp [-h] [-help] [-import_search_strategy filename]
    [-export_search_strategy filename] [-task task_name] [-db database_name]
    [-dbsize num_letters] [-gilist filename] [-seqidlist filename]
    [-negative_gilist filename] [-entrez_query entrez_query]
    [-db_soft_mask filtering_algorithm] [-db_hard_mask filtering_algorithm]
    [-subject subject_input_file] [-subject_loc range] [-query input_file]
    [-out output_file] [-evalue evalue] [-word_size int_value]
    [-gapopen open_penalty] [-gapextend extend_penalty]
    [-xdrop_ungap float_value] [-xdrop_gap float_value]
    [-xdrop_gap_final float_value] [-searchsp int_value] [-max_hsps int_value]
    [-sum_statistics] [-seg SEG_options] [-soft_masking soft_masking]
    [-matrix matrix_name] [-threshold float_value] [-culling_limit int_value]
    [-best_hit_overhang float_value] [-best_hit_score_edge float_value]
    [-window_size int_value] [-lcase_masking] [-query_loc range]
    [-parse_deflines] [-outfmt format] [-show_gis]
    [-num_descriptions int_value] [-num_alignments int_value] [-html]
    [-max_target_seqs num_sequences] [-num_threads int_value] [-ungapped]
    [-remote] [-comp_based_stats compo] [-use_sw_tback] [-version]

   Protein-Protein BLAST 2.2.29+

Use '-help' to print detailed descriptions of command line arguments

I have been using the resulting programs and they work all right so far (at least blastp and rpsblast). I hope this works for you as well. Of course, you can always download the precompiled programs from NCBI instead of compiling them from source.

Have fun!



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s