Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Here's what happens when I try to make

share|improve this question
1  
cd to the source directory and post the output of ls –  Ashu Apr 22 '12 at 1:11
    
Okay, I've ls'ed the source directory. –  John Baber Apr 22 '12 at 1:54
1  
do sh ./build-imgcnv-linux.sh. you can test if it works by typing ./imgcnv -fmt. for installing it pemanently u could try reading the readme.txt or install.if my soln works tell me ill post it as an ans. –  Ashu Apr 22 '12 at 7:11
    
When I run build-imgcnv-linux.sh it ends with a bunch of errors and make install still doesn't work. Thanks for your help so far! –  John Baber Apr 22 '12 at 12:54

1 Answer 1

up vote 2 down vote accepted

Short answer (applies to your specific situation)

  1. Install the qt4-qmake package (or if that's unavailable, the qt3-dev-tools package). Also install the libbz2-dev package. (You can install both from the command-line by running sudo apt-get update followed by sudo apt-get install qt4-qmake libbz2-dev.)
  2. If you don't want imgcnv installed in /usr/bin (which is the default location), edit Makefile and change the first line (which reads prefix=/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 say prefix=/usr/local. If you want to install imgcnv in your home directory, then create $HOME/bin if it doesn't already exist and edit Makefile's first line to read $HOME.
  3. Run make.
  4. Run sudo make install (unless you're installing in your home directory; then run make install).
  5. Assuming that worked, it's pretty clear the official installation instructions are faulty, so optionally, you may want to report this as a bug to imgcnv's maintainers.

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 prevented make 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 run make, or if you are not given instructions, you should then run make.

If there is no configure script (as is the case here), see if there is a file called Makefile. If there is, then run make. (When there is a configure script, this script will often generate the Makefile, or on rare occasion may modify it.) You may first want to edit Makefile to customize options for building or installing. One purpose of a configure script is to render this unnecessary by creating a Makefile that is customized according to your specifications. One of the most commonly customized variables in a makefile is prefix, which controls where the software will be installed. (See the "Short answer" above for a specific example of this.)

Running ./configure or make will sometimes fail, telling you that you don't have something you need. When that happens, you must install that thing. When I ran make, everything seemed to be going well until it eventually failed because the qmake command was not present on my system. Since qmake 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 ran make 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 run make again and it fails, you can run make distclean to bring things back to the way they were before you ran make, then run make. (If make distclean doesn't work, run make clean.)

Sometimes a source distribution has build scripts, like build-imgcnv-linux.sh in imgcnv. If there are both build scripts and a Makefile, and the documentation doesn't tell you to run a build script manually, it's advisable to try running make first, especially if the instructions tell you to run make install. In a properly set up source distribution that has a Makefile, running make install would do the same thing as running make followed by make 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 run make first.

It's advisable to run make before make install anyway, even if you know running make install by itself would take care of the make step automatically. There are three reasons for this:

  1. 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.

  2. 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 either make check or make 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 running make install, and while you might be able to just run make check or make test without running make 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).

  3. 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 as root. On Ubuntu, the proper way to do this is by running sudo make install instead of make install. But you don't need to actually build the software as root, so you can build the software as yourself with make and then install it as root with sudo 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 idiom make && make install. This also addresses the root/non-root issue, as you can run make && 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 an autogen.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.)

share|improve this answer
    
I downloaded a fresh 1.52 directory. I've already got the latest qt4-make, but I can't succesfully 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) –  John Baber Apr 22 '12 at 18:08
1  
@JohnBaber It's hard for me to interpret that error message as you have not indicated where one line ends and another begins. If that's the complete output of make, then please edit your question to include it (then you can comment here to let me know you've done so). If there was a lot of output and that's just the end, then you can select all the text in the Terminal, paste it at paste.ubuntu.com, and comment with a link. –  Eliah Kagan Apr 22 '12 at 19:10
    
Sorry, I forgot that comments can't show code formatting. Here is the pastebin of what happens when I try to make. Thanks for your help! –  John Baber Apr 22 '12 at 20:07
1  
@JohnBaber Install libbz2-dev and try again. (My system already had that, so I never got your error.) In general, when you get cannot find -lX, where X is some sequence of characters, search for an Ubuntu package named something like libX-dev (sometimes there will be numbers in the package name too, though). BTW I'm editing my answer to add information about how libbz2-dev is needed. (And comments do support code formatting, but only the simple kind where you put code between a pair of tickmarks--i.e., "lower case tilde"--which is what I'm using in this comment.) –  Eliah Kagan Apr 22 '12 at 20:16
1  
I see what you mean, I just meant add libbz2 to the list of things I'd done wrong. Your answer is what would have worked from the beginning. I didn't remove the directory again from scratch before running make. All I did was go back in after installing libbz2-dev and maked again and it worked. Thanks again! –  John Baber Apr 22 '12 at 23:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.