HOWTO build programs on SHellium

From SHellium Wiki
Jump to: navigation, search
Geographylogo.png In other languages: English | Afrikaans | Albanian | Arabic | Brazilian | Bulgarian | Catalan | Chinese | Croatian | Czech | Danish | Dutch | Esperanto | Estonian | Filipino | Finnish | Flemish | French | German | Greek | Hebrew | Hindi | Hungarian | Indonesian | Italian | Japanese | Latvian | Lithuanian | Macedonian | Malay | Malayalam | Norwegian (Bokmål) | Norwegian (Nynorsk) | Persian | Polish | Portuguese | Romanian | Russian | Serbian | Slovak | Slovenian | Spanish | Swedish | Turkish | Ukrainian | Urdu

Note: you need permission from a operator to compile programs(try asking Bot:shellium for 15 minnutes of GCC)
To compile a program, first download its source code. Type:

wget http://www.someopensourceproject.org/download/program.tar.bz2

in your home directory to download the source, obviously replacing the URL with your own. You now have to extract the source from the archive. The two most common types of archive are gzipped tarball (tar.gz) and bzipped tarball (tar.bz2). For gzipped tarball you should type:

tar -xzfv program.tar.gz

(x - extract, z - zipped, f - file to extract, v - verbose). The v switch is optional.

For bzipped tarball you should type:

tar -xjfv program.tar.bz2

(j -filter archive through bzip2)

Next, check that all of the files have been successfully extracted from the archive.
First of all, list directory contents:

ls -la

There should be a directory with the name of your program. Usually, if your archive name is program_linux_src.1.30.5.tar.gz, the resulting directory would be program_linux_src.1.30.5. Although this is not a rule, so name might be different. Once you've found it, enter the directory and check it's contents:

cd program_linux_src.1.30.5

ls -la Firstly, we will look for a readme file in case there are any installation notes. It is usually named README or similar. You can view it with the following command:

cat README | more

Any other text editor can be used, ie. nano, pico, ed... If there are no installation notes, look for a file named INSTALL. ls -la again and look for it.

cat INSTALL | more

Many programs have a standard installation procedure:

./configure
make
make install

The INSTALL file should contain this procedure. If there is any other procedure in INSTALL, skip this part.
You are not an administrator on SHellium so we have to tweak configuration a little bit. Before You run configure let's see it's help:

./configure --help | more

What You have to notice is (most common) PREFIX or some similar variable (sometimes it's destdir or something) to change in witch directory You want to install Your binaries. We will presume it's --prefix=PREFIX. You should change PREFIX to some existing directory on Your account. So, it should look like this:

./configure --prefix=/home/limitman/program

(don't use my username ... this is just an example :]). You should see a bunch of text on your screen. If you see in that text that something is not found, but it continues working, it's OK. If it exits with an error, you should see what error it is, find the program that is missing and compile it in your home directory. Than come back to this program we are compiling and see ./configure --help to see how to tell configure where to search for libraries. For example, if it's asking for ODBC drivers, you have to download them, compile them in your home directory and then run configure with:

./configure --prefix=/home/limitman/program --with-unixodbc=/home/limitman/odbc

If you're completely stuck, come to #shellium on Freenode and ask for help. There are many users waiting to contribute.

Now that we have run ./configure, we can see what we have made:

cat Makefile | more

Everything looks ok? Than let's compile the program. Type:

make

Some programs may take a few seconds to compile, others may take hours. You will see a bunch of strange text and sometimes warnings. If make exits with an error, come to IRC and ask for help. You will need to copy the last few lines of output to nopaste at http://shellium.org/np and paste the link in IRC. It compiled successfully? Great! The final step is to install the program.Note: Some programs ask you to build modules, for example eggdrop. If you do, run make modules. Refer to INSTALL to see how to do this.

All we have to type now is:

make install

Change to directory where you installed the program:

cd ~/program/

and type

./program

to start it.

No configure SCRIPT? First look in README or INSTALL if there are instructions. Than look if there is already Makefile file:

ls -la

It is? Great! Than just run:

make

It's not? Only some .c or .cpp files? Than You need to type:

gcc -o outputfile file1.c for single file
gcc -o outputfile file1.c file2.c file3.c for multiple files

or you can use -Wall switch to compile with more error checking

gcc -Wall -o outputfile file1.c

Now, all you have to do is run ./outputfile

Personal tools
Namespaces

Variants
Actions
Navigation
Indexes
SHellium Sites
Toolbox