Tuesday, September 22, 2009

Troubleshooting Linux Open Source Software Compilation Issues

I wrote this post to address issues with custom software that you may want to install on your Linux system. One of the key reasons for using Open Source or Linux is that you have the ability to compile programs from source code. Many times you may want to modify parts of the source code to meet your own needs which is yet another reason to use Open Source code. Keeping in mind that you already know how to locate, download, and untar/gzip the source code. You must also know how to read the README/HOW-TO/INSTALL text files, they will provide important information on the packages that are required to compile or install the software.

Often Open Source software requires operating system, kernel, and other header files that are often referred to as include files to compile programs. If you are using the system without root privileges then you may need to put these required files somewhere in your home directory if they are not detected by the configure script or the compiler when you run the make command. If you are root they can be installed in the default locations and the system should be able to find them.

When installing software it is a good idea to keep track of what you are installing and where in some documentation so you will have a record of the installed software to refer to when you check for software updates or have issues with something. Documentation is a good thing and helpful in all cases.

Many times Open Source software that you download in source form could require other software libraries or other dependencies which are required for the program to compile and run.
You may find that options you choose when you configure the code may require additional software libraries and include files as well.

One common problem people have with compiling open source software is the fact that they may not have a supported OS as some projects get left in the wayside and lose programming support because developers lose interest or other various reasons the project stalls or becomes abandoned.

Ok, enough of the generalizations, hack up some code!!


Example 1:
Here are some of the first few basic issues you may encounter and the ways to resolve them:
[root@centos5_3-1 ntfs-3g-2009.4.4]# ./configure
checking for gcc... no
checking for cc... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
You have no compiler installed. You will need to install gcc or cc the GNU Compiler.


Example 2:
[root@centos5_3-1 ntfs-3g-2009.4.4]# make
from /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:11,
from fuse.c:22:
/usr/include/bits/local_lim.h:36:26: error: linux/limits.h: No such file or directory
fuse.c:2378: error: 'ENOENT' undeclared (first use in this function)
make[2]: *** [libfuse_lite_la-fuse.lo] Error 1
make[2]: Leaving directory `/space/ntfs-3g-2009.4.4/libfuse-lite'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/space/ntfs-3g-2009.4.4'
make: *** [all] Error 2
[root@centos5_3-1 ntfs-3g-2009.4]#

There will be many lines here so you will have to scroll back to determine what files are not found by the compiler so you can know what to add. Obviously here we see linux/limits.h is not there which means that the kernel headers or kernel source is not installed or located where the compiler and software thinks it should be.

This is an easy one to resolve, HOWEVER. It's important to be sure that you have the kernel headers or kernel source code for the kernel you are running, you can view this with the command:
[root@centos5_3-1 ntfs-3g-2009.4.4]# uname -a
Linux centos5_3-1 2.6.18-164.el5xen #1 SMP Thu Sep 3 04:47:32 EDT 2009 i686 i686 i386 GNU/Linux
This would mean that you need to install the 2.6.18-164.el5xen kernel headers, or source for the program to compile. You can see the headers in a directory like /usr/src/linux, /usr/include/linux, /usr/src/kernel, /usr/src/kernels/kernel-version.rel#


Example 3:
[root@centos5_3-1 2.4.9-ac6]# make
gcc -D__KERNEL__ -I/mnt/hda3/kernel/2.4.9-ac6/linux/include -Wall
-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
-march=athlon -DMODULE -DMODVERSIONS -include
/mnt/hda3/kernel/2.4.9-ac6/linux/include/linux/modversions.h -c -o
scsi_lib.o scsi_lib.c
scsi_lib.c: In function `__scsi_end_request':
scsi_lib.c:379: `queued_sectors_Rc37b18c1' undeclared (first use in this
function)
scsi_lib.c:379: (Each undeclared identifier is reported only once
scsi_lib.c:379: for each function it appears in.)
make[2]: *** [scsi_lib.o] Error 1
make[2]: Leaving directory `/mnt/hda3/kernel/2.4.9-ac6/linux/drivers/scsi'
make[1]: *** [_modsubdir_scsi] Error 2
make[1]: Leaving directory `/mnt/hda3/kernel/2.4.9-ac6/linux/drivers'
make: *** [_mod_drivers] Error 2

In this example you will see that we are trying to compile the kernel modules, this error would show us that the modversions.h file may be outdated and need to be recreated. There are many kernel how-to's available on the net so I won't cover how to do this now that you know what is wrong you may research how to resolve the issue.


Example 4:
You were able to get thru all the hoops to compile Firefox, go to start it up and get the following:
/usr/lib/firefox/firefox-bin: symbol lookup error: /usr/lib/libxml2.so.2: undefined symbol: gzopen64
Many errors which complain about undefined symbol are library related, some libraries may be installed but they are not the version which includes the symbol the software is using. It's obvious to see that the libxml2 is at fault and may need to be upgraded.


These are just a few examples of issues you may run into. Now go download some source code, compile, and then run it!

0 comments:

Post a Comment