I'd like to compile imgcnv so that I can chop up images for panojs. imgcnv
's INSTALL directions are extremely curt:
$ pwd
/home/$USER/src/imgcnv
$ ls
build-imgcnv-cygwin.sh INSTALL matlab msvc2010_bimread src_bimread
build-imgcnv-linux.sh libs msvc2008 msvc2010_gobjects src_gobjects
build-imgcnv-macosx.sh libsrc msvc2008_bimread readme.txt testing
changelog.txt LICENCE.txt msvc2008_gobjects scripts
generated Makefile msvc2010 src
$ cat INSTALL
Welcome to imgcnv. A utlity for reading and converting
biological image formats.
1. To install just execute,
$ make install
2. Sit back
I downloaded a fresh 1.52 directory.
I've already got the latest qt4-make, but I can't successfully make:
$ make
/usr/bin/ld: cannot find -lbz2
collect2: ld returned 1 exit status
make[1]: *** [../imgcnv] Error 1
make[1]: Leaving directory `/home/$USER/src/imgcnv/src'
#(cd src; qmake imgcnv.pro)
#(cd src; make)
I'm on 32-bit Oneiric on an intel machine (hp 6220 laptop)
Short answer (applies to your specific situation)
qt4-qmake
package (or if that's unavailable, theqt3-dev-tools
package). Also install thelibbz2-dev
package. (You can install both from the command-line by runningsudo apt-get update
followed bysudo apt-get install qt4-qmake libbz2-dev
.)imgcnv
installed in/usr/bin
(which is the default location), editMakefile
and change the first line (which readsprefix=/usr
). For example, if you want it in/usr/local/bin
, which is the normal place for software you build and install from source (and not through Ubuntu's package manager), make this line sayprefix=/usr/local
. If you want to installimgcnv
in your home directory, then create$HOME/bin
if it doesn't already exist and editMakefile
's first line to read$HOME
.make
.sudo make install
(unless you're installing in your home directory; then runmake install
).This worked for me to build imgcnv 1.52 on an Ubuntu 11.10 Oneiric Ocelot amd64 (i.e., 64-bit) system. If it doesn't work for you, please comment with details (including error messages and the version and architecture of your Ubuntu system).
If it doesn't work for you, you might try deleting your
imgcnv
folder and starting over, re-extracting the archive. Perhaps running the script manually, as you have done, has messed up something that preventedmake
from working.Longer answer (applies also to similar situations)
The standard way to build software from source that has good instructions that work is to follow them. Unfortunately this doesn't.
The standard way to build software from source without instructions (or with non-working instructions) is to see if there is a script called
configure
. If there is, run./configure --help
to see what kind of command-line options it takes. Then run the script, with whatever options are appropriate for your needs. Often you may run./configure
with no options, as the defaults are often acceptable. After running./configure
, you may be given instructions. If you are told to runmake
, or if you are not given instructions, you should then runmake
.If there is no
configure
script (as is the case here), see if there is a file calledMakefile
. If there is, then runmake
. (When there is aconfigure
script, this script will often generate theMakefile
, or on rare occasion may modify it.) You may first want to editMakefile
to customize options for building or installing. One purpose of aconfigure
script is to render this unnecessary by creating aMakefile
that is customized according to your specifications. One of the most commonly customized variables in a makefile isprefix
, which controls where the software will be installed. (See the "Short answer" above for a specific example of this.)Running
./configure
ormake
will sometimes fail, telling you that you don't have something you need. When that happens, you must install that thing. When I ranmake
, everything seemed to be going well until it eventually failed because theqmake
command was not present on my system. Sinceqmake
is a command, I tried to run it manually, which gave me a detailed message telling me I didn't have it (which I already knew) and what packages I could install to get it. Then I installed one of those packages (qt4-qmake
) and ranmake
again. (If it had been a library or header files, I might have needed to search at http://packages.ubuntu.com to see what provides it.)Running
make
again will often be able to pick up where it left off (or even if not, then from somewhere later than the beginning). Some software--including imgcnv--can take quite some time to build, so it's a good idea to try to pick up where you left off. Occasionally this causes problems though, so if you runmake
again and it fails, you can runmake distclean
to bring things back to the way they were before you ranmake
, then runmake
. (Ifmake distclean
doesn't work, runmake clean
.)Sometimes a source distribution has build scripts, like
build-imgcnv-linux.sh
in imgcnv. If there are both build scripts and aMakefile
, and the documentation doesn't tell you to run a build script manually, it's advisable to try runningmake
first, especially if the instructions tell you to runmake install
. In a properly set up source distribution that has aMakefile
, runningmake install
would do the same thing as runningmake
followed bymake install
(i.e., it would see that the software hadn't been built yet, and it would build it before attempting to install it). But sometimes that doesn't work, so then you have to runmake
first.It's advisable to run
make
beforemake install
anyway, even if you know runningmake install
by itself would take care of themake
step automatically. There are three reasons for this:If anything happens during the
make
step that causes you alarm (even if it isn't an error), you're not installing software that might not be built the way you want it. For example, there could be warnings advising you of potential problems.This doesn't apply to
imgcnv
. But many source distributions come with testsuites to see if the built program is likely to work properly. You can build and run them with eithermake check
ormake test
. (If the documentation doesn't say anything about them, I recommend trying those commands in that order.) These don't get run automatically by runningmake install
, and while you might be able to just runmake check
ormake test
without runningmake
first, that's undesirable because it might not be clear if an error happened while building the software or while building/running the testsuite (which is crucial information for troubleshooting the problem).If you're installing the software for the whole system (rather than just your user), which is almost always the default configuration, then
make install
needs to be run asroot
. On Ubuntu, the proper way to do this is by runningsudo make install
instead ofmake install
. But you don't need to actually build the software asroot
, so you can build the software as yourself withmake
and then install it asroot
withsudo make install
.If you're sure you want to both build and install (no matter what kind of scary warnings come out of building) and
make install
doesn't work, you can use the idiommake && make install
. This also addresses theroot
/non-root
issue, as you can runmake && sudo make install
. The&&
operator, used in this way, causes the command to the right of it to run only if the command to the left of it seems to have succeeded.(I've intentionally left out discussion of how to build software that requires the user to invoke
autoconf
,automake
, and/or anautogen.sh
script, as source code of stable releases very rarely requires this. However, if someone wants to edit this post an add instructions covering those situations, under a third subject heading, I would have no objection.)