Environment and tools
- CLion 2020.1.1(C++ IDE, compiledb doesn’t work in older version)
- Clang (macOS compile tool)
- CLion plugins Makefile support、Compilation Database
- python 2.7+ with pip
- python package compiledb(blast exectuables were built on GNU Make, when debugging the source code, header files(.h) need to be imported in CLion)
Where to dowload latest ncbi blast+ source code?
All blast+ exectuables are in ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/, and download the source code of 2.10.0 through ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.10.0/ncbi-blast-2.10.0+-src.zip
How does folders look like?
unzip the file, there are four folders(compilers, include, scripts and src) and two files(configure and configure.orig), like below:
How to build debug exectuables?
Step 1. generate makefiles
1 | cd ncbi-blast-2.10.0+-src/c++ |
After above commands executed successfully, DebugMT folder with lots of makefiles created. C++ files such as .o(object file) .d(dependency file) binary(executable) will be created in Step 3.
Step 2. using compiledb generate compile_commands.json
1 | cd ncbi-blast-2.10.0+-src/c++ |
After above commands executed successfully, C++ link information will be written into compile_commands.json file.
Step 3. use make to compile whole source code at first time
1 | cd DebugMT/build/ |
Note: it will take about 45 minutes to build whole exectuables
After above commands executed successfully, the exectuables will be created under build/app/ and bin/
Step 4. use CLion open compile_commands.json as a project,
Note: before that, please install Compilation Database
CLion plugin
CLion will index headers according to compile_commands.json created in Step 2, and you are able to see headers in Extranal Libraries, and can open the import file by clicking it as below:
Step 5. Debug in CLion
- Configure Toolchains using LLDB
- Create an External Tools called Empty, here not using any external tool.
- Use Empty tool, and rename Custom Build Targets as LLDB.
Click Run → Choose Edit Configurations… → Click Add to create Custom Build Application → Select LLDB as Target → Select DebugMT/build/blastp as Exectuable → Remove Build in Before launch
Click Add in Before launch → Click Add in External Tools → Create one called clean_blastp to clean .o, .d, binary files under DebugMT/build
And keep Arguments as below: ‘-rf DebugMT/build/app/blast/blastp DebugMT/build/app/blast/blastp_app.d DebugMT/build/app/blast/blastp_app.o’
- Click Add in Before launch → Click Add in External Tools → Create one called make_blast to build executables(if blastp is missing, make command will generate another new one exectuable called blastp)
- Rename it as rebuild_blastp, keep clean_blastp and make_blast are selected in Before launch.(This one is to debug after source code changing)
- Create another Custom Build Application called debug_blastp, and keep empty in Before launch. (This one is only to debug)
- Fullfill correct arguments in Program arguments for debug_blastp, like
- Set breakpoint at src/app/blast/blastp_app.cpp, and debug debug_blastp