Installing programs from source code ………….. have you done it before? (tutorial)

February 21, 2009 at 9:11 pm (Linux installation) (, , , , , , )

This article is intended for intermediate users on how to compile from the source code.

As I mentioned before, it’s a free and open source world that we are living. So people who want to help others not only just give away the programs, but they give out the source code (the program codes used to build the program) in order to modify, learn the codings ,algorithms used, so that other people can use that code to build something much more better ! That’s how FOSS came this far down the lane, and it seems to get more and more enthusiastic !

As you know, source code as well as the pre-compiled binaries (ex: rpm, deb, bin) are available to download in the FOSS cloud. See far down this article to see when you do need to go for the source.

Short eats for beginners

basic steps to install

open commandline, CD in to the folder where you have the tarball (.tar.gz,.tar.bz2)

untar the source file using tar -xvf <filename>

CD in to source folder

then type

sudo ./configure && make && make install

or type su – , enter the root password and type

./configure && make && make install

If you have luck you’ll succeed. Read down for more deatiled description.

How to get source codes of programs?

There are several sites hosting FOSS programs, but I would suggest you go and check out sourceforge.net, freshmeat and softpedia linux page. When you come to the download page you will find a list of files to download. Don’t download unstable editions. Source file is something usually in .tar.gz or .tar.bz2 format saying “any platform” , sometimes may be categorized under “other OS”.

The source folder

(from here you should use console/terminal)

A typical view of the source folder

A typical view of the source folder

Change directory using CD command to the path you saved your file

Untar the downloaded file either using tar -xvf <filename> (ex: tar -xvf mplayer-1.02RC3.tar.gz) or your OS’s GUI extractor (ex: fileroller) to a folder newly created by mkdir <newdirectoryname> command. (I guess you know these)

now CD in to the folders till you find some lot of files (see below – use command ls for list the files in each directory) which is called the source folder. It usually includes a README, INSTALL, COPYING, configure and Makefile. (Doesn’t need to have all of these)

Task of these files: (can be omitted in a short course)

configure – Sources are designed to install with any system, but how it should install in a given system is heavily different. It depends on your hardware, software and “your choice”. When run, this will make a config.h, config.status and various config files and a unique Makefile

Makefile – Make file includes the code to compile the program calling files from source folder.

Autogen.sh – capable of generating a configure file

README – YOU MUST READ THIS FILE ! It includes information about the program, and dependencies etc. use command

less README

INSTALL – YOU SHOULD READ THIS TOO ! This gives specific information on how to install program.

Start compiling

Start with ./configure –help

this gives out some flags like below ones: (features of install)

flags you need to note:

–prefix=<path where you want to install files> , by default this will be /usr/local/bin etc…

–with-<packagename> ,will use the given package (as in the list)

–without-<packagename> , will not use

–enable-<feature>, enable a feature in the program

–<packagename>-includedir or -includes , manually override the search path for dependencies

now start configuring by

./configure flag1 flag2 flag3 etc….

ex: ./configure –prefix=/mnt/storage/mplayer –enable-gui –without-libmad

or just type ./configure only, this will work for most programs and easy for beginners

A typical text output when configure is run

A typical text output when configure is run

the program will display text as it is checking for dependencies, it will stop if it found out that a critical component is missing (or can’t find) and will display error and the package failed in someway. (see debugging below) if you’re lucky the text will show up to the point it’s writing config files ! Some advanced programs will show a list of things it’s planning to install, according to your dependencies.

Now type

make

This is gonna take some long time —— and this is where you need the luck most as many programs fail here ! (Now you say that) when done, type (see below the picture)

The make has failed - you should need to re configure

The make has failed - you should need to re configure

sudo make install

or log in to root typing su – then type make install

this will install the program. If you didn’t use “–prefix=” above, you”ll have binaries in your PATH so type

ls *<name of program you installed>*

ex: ls *mplayer* , this will give you a list of possible commands to run the program. Type them and see the correct one. (there’s a possiblity you may have a link in desktop) if you installed somewhere else go inside that folder. You may find the script usually in bin folder. Type

./filename

to run program.

Debugging:

1. There’s a possibility that you don’t have a configure file. Anyway,
still you have autogen.sh – What you downloaded is a snapshot. Type ./autogen.sh to generate configure file.
You have Makefile – no need to do “./configure” only do make and make install steps.
You have some files named cmake – your program does not install from ordinary automake. It’s using a program called cmake. Make a folder named “build” in your source folder and type

cmake ../ -DCMAKE_INSTALL_PREFIX=<path of your source folder>/build
and continue with make and make install
You have some .jar files – Source code is java. (Sorry i’m NIL at java, anyway try java -jar filename.jar)

2. If Config says you don’t have a package installed or something like that it could be due to

*You actually don’t have program installed. Copy the name in to google search and try to find it’s homepage to download. If you are installing binaries (ex: rpm) make sure you have both the “package” (has the program) and “package-devel” (has header files .h to develop the program)

ex: if it says “WxWidgets not found” install both “WxWidgets” and “WxWidgets-devel”

(there may be an article on my blog about manual rpm installation). If you only have the “package” configure will still say that you don’t have the package.

*You have the program and devel installed, but configure is searching some where else. Type

locate <packagename> | less

to list the files, the folder path having most “.h” files with “include” in path name may be where your header files are. Copy that path and do configure again using –<packagename>-includedir flag.

Ex: ./configure –Qt4-includedir=/usr/include/Qt4

3. If you still can’t debug it you may need to edit the configure file (not recommended), copy the error message and type

gedit configure

or if you have kwrite, nano other editor, use that command. Use find option pasting the error message. If you have some programming knowledge you should be able to identify the default paths assigned for searching for the package. Correct them to your actual path.

(For example, package WxGTK is installed as compat-WxGTK in fedora, so I had to tell the program that compat-WxGTK is the correct one while installing audicity ).

Man, this is getting longer and longer so i’ll stop here. You can always google search for the error message, where people may have solved it before have put how they did it. (Of course you can ask me)

It’s a good practice to type

make clean

to remove the make files after installation or failed make attempt.

You can type this to uninstall, if you’re at the source folder.

make uninstall

so I suggest you shouldn’t delete the source folder just after successful installation !

Some configure scripts will need

make depend

make check

commands between the make and make install. These will be mentioned in INSTALL file.

When should you go for source?

  • If you are a developer, who either using the code for modifications or a someone who’s building binary repositories for various Linux distributions by cross-compiling
  • You don’t have a package managing system (ex: rpm,deb) or only the source code is available so you don’t have a choice
  • The program is large or it has many unwanted features which is again large and asking for a list of dependencies to run when you try to install the .rpm or .deb (you can select features to install by source code – saves a lot of space)
  • Person who want to grab the newest edition
  • Some programs have tweaks (optimizations) chosen when compiling depending on your system. This enhances performance of program (ex: wine, mplayer, swiftfox)

Important: Anyway, use the source mainly for programs up in the dependency tree (programs which heavily depend on other programs but which is not a dependency of any program) if you have a package manager (as it may not identify the installed program).

I’ll stop here for now. This blog page will be updated as necessary in the future.

Permalink 6 Comments

Maxima : The maths notebook

February 18, 2009 at 10:42 pm (linux apps) (, , , , )

This article is about mathematica-like FOSS application maxima.

WxMaxima running on FC9, Gnome

WxMaxima running on FC9, Gnome

I usually get big intergrations and ODE’s which i cannot solve on my own. Functions of these without boundry conditions cannot be solved by most programs, and most of them give alien output which is far different than your school notebook. This is where maxima comes in with built in functions. You can check out maxima website for more details.

Maxima runs using LISP. There are several distributions of LISP, but i recommend common lisp alias CLISP (type clisp on rpmfind for rpms- or download source from here) for the purpose. It’s slow than others, but less-troublesome. You should install CLISP before installing maxima. If you’re installing from source (download here) it will be auto-detected. The same old method, which is to CD in to source folder path and typing (this contains “configure” file)

./configure

make

make install will install your app.

If downloading from binaries choose package which suits your installed LISP package.

ex: download maxima-runtime-clisp if you installed CLISP as your LISP.

maxima-runtime-elisp if you installed ELISP as your LISP etc.

When you’re done installing maxima, type maxima for command line interface and xmaxima for inbuilt GUI. The xmaxima also contains some example codes.

The xmaxima inbuilt GUI

The xmaxima inbuilt GUI

Recommende GUI – WxMaxima (see the first picture)

Although xmaxima is good, it lacks modern  GUI touch. wxwidgets have good solution for this, and this even includes openmath software for pretty plotting than from GNUPLOT. You can download the source from this link.

Permalink Leave a Comment

Octave – The FOSS Mathlab clone

February 17, 2009 at 3:00 pm (linux apps) (, , , , , , )

This article is about installing octave and it’s plugins on linux

Qtoctave 0.8 on FC9, Gnome

Qtoctave 0.8 on FC9, Gnome

I guess you people have heard of mathlab. If you’re a student doing higher education on maths-based stream, you have had to use mathlab in your programs. Octave is the most mathlab like program you find on FOSS cloud. It accepts basic mathlab commands. It can even install mathlab toolboxes and  run and edit .m files ! Wow this is amazing

You can install octave from source from here ftp://ftp.octave.org/pub/octave/octave-3.0.3.tar.gz

You should go and check out their website and also my article on installing from source and the dependencies you need. Rpmfind have rpm packages for fedora and suse.

some basic commands on octave: (type and see)

octave:1> 2+5 (press enter and you’ll get)

ans = 7

octave:2> x=[1:0.1:10];

octave: 3> y=sin(x);

octave:4> plot (x,y)     ‘you’ll see the grapg of sin(x) !

——————————————————————————————————————————–

Recommended GUI – Qtoctave

You may wondered where the hell is the gui ! You’ve to install it seperately. Only dependency is that you should have Qt4 + and octave installed. Click on this link to go to the download page. Else you can try Rpmfind. (type qtoctave)

Plugins for octave

_________________________________________________________________________

YAPSO (Yet Another Plotting System For Octave)

An rotating output (plot) from yapso

An rotating output (plot) from yapso

By default, octave will use GNUPLOT which is fast but not nice. Installing yapso will increase the “mathlab – likeness” of octave plots. Installing is simple; you should download the source tarball from this link; and run octave in command line by typing octave.When octave command prompt is there, type

octave:1> pkg install /<path to downloaded file>/<file name> ‘example        pkg install /mnt/yapso-0.3.4.tar.gz

if dependencies are ok and no compile errors, pckage will install. Restart octave (type exit to exit) and type

pkg load yapso

to load yapso as default plotter, else GNUPLOT will work as plotter. Go to this page for some examples. Type pkg unload yapso to return to GNUPLOT.

Octave-fltk : a GUI builder for octave !

octave-fltk GUI developer

octave-fltk GUI developer

As you know mathlab can build GUI programs using VB.net core. This plugin enables you to use fltk graphics library for GUI creation. Download source from here Use usuall compile methods to make the package.

there are so many other packages like nnet, mataa and ltfat. You can sure try those!

Permalink 4 Comments