]> git.donarmstrong.com Git - mrbayes.git/blob - src/CompileInstructions.txt
import mrbayes
[mrbayes.git] / src / CompileInstructions.txt
1 \r
2 Content\r
3 =======\r
4 \r
5 1) How to compile MrBayes from source\r
6 2) Configuration options\r
7 3) Troubleshooting for Mac\r
8 4) Tips for Windows\r
9 5) Further references\r
10 \r
11 \r
12 How to compile MrBayes from source\r
13 ==================================\r
14 \r
15 Pre-requirements:\r
16 * gcc (or other C compiler)\r
17 * autotools (autoconf, automake, etc)\r
18 * optional: MPI compiler and library\r
19 * optional: BEAGLE library\r
20 \r
21 Compilation: \r
22 To compile MrBayes in UNIX-like environments, first navigate to the folder containing\r
23 the source code, then execute the following commands in your terminal (without '>'):\r
24 \r
25 > autoconf\r
26 > ./configure \r
27 > make\r
28 \r
29 The compilation will produce an executable in the source directory with the name "mb". \r
30 To start the program, simply type\r
31 \r
32 > ./mb\r
33 \r
34 For more convenient access to the program, you may want to install it in your path, in\r
35 which case you can invoke the program from any directory by simply typing\r
36 \r
37 > mb\r
38 \r
39 If you wish to make the program available to all users in this way, you can use\r
40 \r
41 > sudo make install\r
42 \r
43 after having compiled the program.\r
44 \r
45 \r
46 Configuration options\r
47 =====================\r
48 \r
49 1) BEAGLE\r
50 MrBayes 3.2 uses the BEAGLE library by default. You should install the library from \r
51 "https://code.google.com/p/beagle-lib", or disable the use of the library with option\r
52 "--with-beagle=no", i.e. \r
53 \r
54 > ./configure --with-beagle=no\r
55 \r
56 Note: without BEAGLE library MrBayes may run slower. For more instructions, please see\r
57 https://code.google.com/p/beagle-lib/\r
58 \r
59 2) SSE code\r
60 All main-stream modern processors have support for SSE instructions which are utilized \r
61 by default by MrBayes 3.2 in order to substantially speed up execution. If you \r
62 experience problems with the SSE code, you can disable the use of SSE code with option \r
63 "--enable-sse=no", i.e.\r
64 \r
65 > ./configure --enable-sse=no\r
66 \r
67 If you use SSE code, you may encounter problems with older compilers. Specifically,\r
68 if you are getting errors about undefined references to "posix_memalign", you should\r
69 update your compiler. You should have libc library of at least version 2.1.91 for the \r
70 SSE code to compile.\r
71 \r
72 3) MPI version\r
73 To make use of MPI code to parallelize MrBayes computations across several processors\r
74 or CPU cores, you should invoke the configure script with option "--enable-mpi=yes".\r
75 The MPI code can be used together with the BEAGLE library and the SSE code. Your \r
76 computer also needs to have an MPI implementation installed, for instance OpenMPI or \r
77 MPICH, and the environment needs to be set up to run MPI programs. To install an MPI \r
78 version of MrBayes with BEAGLE and SSE, use:\r
79 \r
80 > autoconf\r
81 > ./configure --enable-mpi=yes\r
82 > make\r
83 \r
84 The resulting program will be called mb. A typical run might be started with a command\r
85 like:\r
86 \r
87 > mpirun -np 8 mb data.nex > output.txt &\r
88 \r
89 This will run MrBayes on eight processors or cores (-np 8), using the data file\r
90 "data.nex" as input. The output will not be printed to screen but to the file\r
91 "output.txt" (> output.txt). The ampersand (&) causes the control to return immediately\r
92 to the console, while the job will continue running in the background.\r
93 \r
94 To examine the most recent output from the run, you might e.g. use the tail command of\r
95 UNIX like this:\r
96 \r
97 > tail -f output.txt\r
98 \r
99 This will print the lines onto the screen as they get added to the file "output.txt".\r
100 To stop the output, simply press ctrl-C (this will stop the output from the tail\r
101 command, it will not stop the MrBayes run).\r
102 \r
103 4) Debugging\r
104 For testing or developing purpose, you may need to compile a debugging version by \r
105 invoking the configure script with the option "--enable-debug=yes", i.e.\r
106 \r
107 > ./configure --enable-debug=yes\r
108 \r
109 \r
110 Troubleshooting for Mac\r
111 =======================\r
112 \r
113 Problem: > autoconf: command not found\r
114 \r
115 Solution: Xcode 4.5 or later no longer ships with autotools, including autoconf that \r
116 is used by MrBayes and most other open-source Unix software packages.\r
117 To install these tools, we recommend using HomeBrew, see below.\r
118 \r
119 Problem: The compilation process hangs on model.c. For instance, this happens when \r
120 using the compiler that ships with Xcode 4.6 (in the command line tools).\r
121 \r
122 Solution: Install newer command line tools (e.g., in Xcode 5 or higher), or install a \r
123 different gcc version for Mac using HomeBrew, see below.\r
124 \r
125 -----------------------\r
126 To install missed Unix tools, we recommend using HomeBrew (http://brew.sh). Follow the\r
127 instructions on HomeBrew's homepage to install it on Mac.\r
128 Other options include MacPorts (http://www.macports.org), GNU (http://www.gnu.org),\r
129 and Open MPI (http://open-mpi.org).\r
130 \r
131 To install autoconf and automake after having installed HomeBrew, use:\r
132 \r
133 > brew install autoconf\r
134 > brew install automake\r
135 \r
136 To install the most recent version of openmpi, use:\r
137 \r
138 > brew install openmpi\r
139 \r
140 Simply, you can directly install MrBayes using HomeBrew:\r
141 \r
142 > brew tap homebrew/science\r
143 > brew install mrbayes\r
144 \r
145 The dependent formulas will be installed simultaneously. To enable MPI and BEAGLE, use:\r
146 \r
147 > brew install mrbayes --with-beagle --with-mpi\r
148 \r
149 To uninstall mrbayes, use:\r
150 \r
151 > brew uninstall mrbayes\r
152 \r
153 To install an alternative gcc (not recommended), use the following commands:\r
154 \r
155 > brew install gcc\r
156 \r
157 After installation, you might need to redirect the symbolic gcc link in /usr/bin/ to the\r
158 new version of gcc. For instance, you can use the following commands:\r
159 \r
160 > sudo mv -i /usr/bin/gcc /usr/bin/gcc-old\r
161 > sudo ln -s /usr/local/bin/gcc-4.9 /usr/bin/gcc\r
162 \r
163 \r
164 Tips for Windows\r
165 ================\r
166 To compile MrBayes in Windows is relatively not straightforward. You can use Microsoft \r
167 Visual Studio to open and build one of the projects in the "projects" folder, after\r
168 downloading all the files from SourceForge (e.g., Download Snapshot).\r
169 http://sourceforge.net/p/mrbayes/code/HEAD/tree/\r
170 \r
171 Here we introduce another way to compile using MinGW (http://www.mingw.org/). You need\r
172 to download the installer "mingw-get-setup.exe" and install it in Windows. Then open \r
173 "MinGW Installation Manager" you just installed. Click the square before "mingw32-base" \r
174 under "Basic Setup" and choose "Mark for Installation", then choose "Apply Changes" from\r
175 the "Installation" menu. \r
176 \r
177 Additionally, add "C:\MinGW\bin" (path to your MinGW installation) to your system path\r
178 in setting "Environment Variables" (please Google :))\r
179 \r
180 Open Command Prompt (cmd.exe), "cd" to the src folder you just downloaded, e.g., \r
181 \r
182 > cd Downloads\MrBayes\trunk\src\r
183 \r
184 and use the following command to compile:\r
185 \r
186 > gcc -O3 -DNDEBUG -o mb bayes.c command.c model.c mcmc.c likelihood.c proposal.c sumpt.c utils.c best.c mbbeagle.c -lm\r
187 \r
188 An executable named "mb.exe" will be generated in the same folder, if everything\r
189 goes smoothly. You may want to edit the fist few lines in bayes.h to define/undef\r
190 some macros (SSE_ENABLED, etc).\r
191 \r
192 \r
193 Further references\r
194 ==================\r
195 \r
196 See the manual for more compilation/installation instructions.\r