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.

Advertisements

Permalink 6 Comments

Installing linux players on fedora.

November 2, 2008 at 1:50 pm (Audio / Video, linux apps, Linux codecs, Linux installation) (, , , , , , )

This article is about using redhat package manager (RPM) to install Mplayer, xmms player, real player etc… on Fedora and redhat. I hope same techniques can be used for Suse and Mandriva.

For each of the given names of packages  below visit www.rpmfind.net or rpmsearch, and copy and paste the package name.

===============================================================================================

edit on 19/01/2010

Now it is much easier to install programs using yum and apt-get than from installing from the source. If you have set your repositaries correctly, following should work.

for  installing both mplayer and vlc player

p { margin-bottom: 0.08in; }

sudo apt-get install gmplayer vlc (for debian based systems)

yum install mplayer-gui vlc (for rpm based systems)

The information below were written two years ago and pretty much deprecated by now. 🙂

================================================================================================

Indentify your architecture (for pentium, dual core, C2D, athlon XP it’s i386 (x86); for 64-bit it’s x86_64. Learn more about RPM’s on my “Managing RPM’s” blog on linux installation category (This post may be pending). For example, you have p4, fedora9 and you want xmms, you choose

xmms-1.2.11-1.20071117cvs.1.fc9.i386.rpm note fc9 tag and i386 (if no tag is there, or noarch is there, you can choose for any architecture/fedora version).Package name with FC9 i386 compitable link as example.

1.Mplayer

mplayer-1.0-0.44.rc2.fc9.i386.rpm

2.Realplayer

http://www.real.com/realcom/R?href=http://forms.real.com/real/player/download.html?f=unix/RealPlayer11GOLD.rpm (for all fedora dist, any arch)

3.Helixplayer

HelixPlayer-1.0.9-2.fc9.i386.rpm

4.xmms player, for this you need

xmms

xmms-1.2.11-1.20071117cvs.1.fc9.i386.rpm

xmms-mp3

xmms-mp3-1.2.10-16.fc7.i386.rpm

continue with xmms-wma, xmms-skins if necessary xmms-libs

5. Gstreamer-ffmpeg

gstreamer-ffmpeg-0.10.5-1.fc9.i386.rpm

for mp3 for gstreamer use fluendo codec (google this to find a downloadable link)

for installing RPM’s, type in command line

su –

passwd:(Enter your pasword here)

rpm -ivh (rpm file) example:

rpm -ivh /home/malshan/HelixPlayer-1.0.9-2.fc9.i386.rpm

if no dependency errors found, now you’ve got program installed. Right clicking on a file on your explorer and saying to open with this program automatically sets that type of file with the program.

enjoy!

If any errors found, please reply.

sudo apt-get install gmplayer (for debian based systems)

yum install mplayer-gui (for rpm based systems)

Permalink Leave a Comment

Mounting NTFS on linux (if not auto mounted)

November 2, 2008 at 3:14 am (Linux installation) (, , , )

This article is about linux distribution which support NTFS but not automount them. ex: Ubuntu (<7), fedora (>4) etc. More newer ones will have drives mounted on /mnt or /media

Many people complain about cannot able to access windows NTFS partitions in linux. Here’s some help.

Open your console/command line, and type:

su –

passwd:(enter your passwd here)

this will login you as admin inside commandline. Now type,

fdisk -l

this will show a list of drives (mounted/unmounted) — indentify your windows drives by size (in kB – in Blocks column) and note down the device name under device column. If you have more than one HDD, the fdisk output gives them different letters starting from a,b. ex: primary hard partitions will start from sda, here i have shown only the output for my second hard drive which is sdb).

for example:

Device Boot      Start         End         Blocks                   Id           System
/dev/sdb1               1        1305         10482381             c           W95 FAT32 (LBA)
/dev/sdb2            1306     16708     123724597+         f           W95 Ext’d (LBA)
/dev/sdb3   *      16709     16721   104422+              83          Linux
/dev/sdb4           16722     19929    25768260            8e          Linux LVM
/dev/sdb5            1306      9137      62910508+          7            HPFS/NTFS

note down the /dev/sdb5 in a paper along with the drive name (identified by size), which is a NTFS partition.

now goto /mnt and make a directory

cd /mnt && mkdir (whatever name you call the drive)

ex: mkdir malshan

now we need to open rc.local file, any command written here will be executed at boot

gedit /etc/rc.d/rc.local

if you don’t have gedit type,

kwrite /etc/rc.d/rc.local

in the window, add this line to end (append)

mount (device) (folder you created)

ex: mount /dev/sdb5 /mnt/malshan

will mount the drive to /mnt/malshan, now you can just

cd /mount/malshan && ls to see the contents; after rebooting

(Note that you can type mount /dev/sdb5 /mnt/malshan in command line to mount it now, but that’s temparaly)

follow same procedure for other drives, after mkdir different folders (ex: malshan2). ex:

mount /dev/sdb6 /mnt/malshan2 , add to rc.local.

Note that, mounted drives are considered as normal linux folders and files.

if you need to mount an iso image, you can use

mount -t iso9660 -o loop (imagefile) (mount folder) ex:

mount -t iso9660 -o loop /mnt/storage/fedora9_live.iso /media/fedora

if your linux doesn’t auto run pen drives, (no pop up) check /media folder, where normally CD’s, DVD’s or flash drives are auto mounted.

enjoy!

Permalink 1 Comment