160 likes | 328 Views
Morty Abzug 2014-03-19. Compiling and Building Tutorial. Background. Notes with a lot more material than we have time for are at: http://frakir.org/~morty/lue/compiling-tutorial/ AKA http://goo.gl/tR6Etu Lots more info can be obtained by searching google. What is building?.
E N D
Morty Abzug 2014-03-19 Compiling and Building Tutorial
Background • Notes with a lot more material than we have time for are at: http://frakir.org/~morty/lue/compiling-tutorial/ • AKA http://goo.gl/tR6Etu • Lots more info can be obtained by searching google
What is building? • Programs are often distributed in formats that are not suitable for immediate use • Building is the process of converting programs from a source code distribution into a form useful by the computer • Distribution in source form is important in research, where we want results to be transparent and reproducible • See background page for more information
Do Researchers need to build? • Many orgs have in-house personnel who can do the building for you. • At NCBI, this is systems. Create a ticket with us. • If you are not NCBI, hopefully you have an equivalent • So why are we having this talk? • Some people are do-it-yourselfers • Some people don't have in-house personnel • Some people want to learn for their own software
Meta Directions • Read directions! • Online at the website • In the distribution, in a README or INSTALL file • If you run into errors • look at the first error. Errors cascade. • Search google for errors • Contact the author if needed. • Feel free to contact local support personnel if available! Helping you is our job. • If you have admin privileges, you have the choice to install to your home directory/profile or to system areas. If you do not have admin privileges, you may only install to your home directory/profile.
General directions • [We'll go into detail on each step] • Make sure you have a build environment set up • Download software • Check distribution expansion (optional) • Expand distribution • Configure • Actual build • Test the build • Install • Test the installed binaries
Setting up a build environment on Ubuntu/Debian • sudo apt-get update; # update the collection of software available • sudo apt-get dist-upgrade; # update all your software • sudo apt-get install build-essential; # install lots of build tools • If you need to install some specific package – say, erlang: • sudo apt-cache search erlang | less; # search for an erlang package • sudo apt-get install erlang; # install the erlang package
Download • Always find the official source for the program. Otherwise, you can end up with out-of-date software. • Usually download with your webbrowser • Or you can right-click a URL, select "copy link location", and then in a terminal window: wget PASTED_URL • Download class notes and samples: wget -m http://frakir.org/~morty/lue/compiling-tutorial/
Check distribution expansion (optional) • Some files expand to a subdirectory. Some expand to the current directory. • for .tar.gz, .tgz, .tar.Z files: tar tzpf FILE.tar.gz | less • for .tar.bz2 files: tar tjpf FILE.tar.bz2 | less ; # note "j" • for .tar files: tar tpf FILE.tar | less • for zip files: unzip -l FILE.zip | less
Expand distribution • If the distribution does not create a subdirectory, make one (mkdir subdir), cd into it (cd subdir), and expand the file using .. before filename below: tar xzpf ../FILE.tar.gz • for .tar.gz, .tgz, .tar.Z files: tar xzpf FILE.tar.gz • for .tar.bz2 files: tar xjpf FILE.tar.bz2; #note the j • for .tar files: tar xpf FILE.tar • for zip files: unzip -q FILE.zip
Configure • If a script named "configure" is present, run it: ./configure • If Makefile.PL is present, run instead: perl Makefile.PL • If Imakefile is present, run instead: xmkmf -a • You can pass options to configure and Makefile.PL. The most useful is for non-default installation location: ./configure –prefix=$HOME/somepackage
Actual build • Normally: make
Test the build • Normally: make test
Install • If you don't have admin admin priviliges: make install • If you do have admin priviliges, you may run: sudo make install
Test the installed binaries • This is program-specific
Installing binaries • This talk was mostly about installing source. • to install binaries in Ubuntu/Debian package format: sudo dpkg -i FILE.deb • To install binaries in RedHat/CentOS/Fedora: sudo rpm -Uvh FILE.rpm