Difference between revisions of "CompilingRHEL"

From Inkscape Wiki
Jump to navigation Jump to search
Line 224: Line 224:
</tt>
</tt>


If you want to rebuild a component you will need
If you want to ''rebuild'' a component you will need
to do the following first:
to do the following first:



Revision as of 00:17, 21 February 2010

Greeting

This page documents the process I used to build Inkscape 0.47 on RHEL4. Many consider RHEL4 to be an archaic operating system. I think of it as mature, stable and predictable.  :-)

Background and Motivation

The corporation I work for is not free to run the latest OS versions. We are constrained by our major application vendors. That leaves us stuck on Red Hat Enterprise Linux (RHEL) Version #4, which appears to come bundled with Inkscape 0.44

Meanwhile I'm watching all sorts of cool Inkscape tutorials on the web, but they use later versions.

My sys-admins would not consider an Inkscape upgrade due to the contamination issue noted below. The build process documented here avoids system installs by using a local install directory.

This is an old-school build as I download and compile source code and do not use any RPMs.

I performed this process on 19-FEB-2010 so this information is already out of date.

List of packages

Following is the list of packages which I used.

The process by which I arrived at this list was no small feat iterating over 15 hours. I consider it a miracle that I was able to find a compatible set of packages and C++ compiler.

They are listed here in the order in which I built them. This is not the only build order. You can't tell by looking, but gc6.8 has no dependencies and so could be built at any time. The pango-1.24.5 package, on the other hand, requires cairo-1.8.8 and so the cairo package must be built first.

Not all of the packages listed here are the latest version which was available at the time that I performed the build. In several cases I had to back out 1 or 2 years because my compiler of choice (gcc 3.4.4) did not like the more recent versions.

  1. libpng-1.2.41
  2. pixman-0.17.4
  3. freetype-2.3.9
  4. fontconfig-2.8.0
  5. cairo-1.8.8
  6. glib-2.22.3
  7. pango-1.24.5
  8. jasper-1.701.0
  9. atk-1.29.4
  10. gtk+-2.17.0
  11. libsigc++-2.2.0
  12. gob2-2.0.16
  13. glibmm-2.22.0
  14. cairomm-1.6.4
  15. pangomm-2.26.0
  16. gtk+-2.18.7
  17. gtkmm-2.18.2
  18. gsl-1.13
  19. gc6.8
  20. libxml2-2.7.6
  21. libxslt-1.1.26
  22. lcms-1.19
  23. inkscape-0.47

How to find a package

I'm sorry that I do not include the location where I found each library. I did not think to write that information down at the time. Especially since I had no confidence in this entire process.

I do remember that they were not hard to find.

Perform a google search for the string "lib<package-name download" For example:

"libgc download"

Or, perhaps:

"gtkmm download"

You will get multiple hits, but hopefully one near the top will link to an obvious home page for the package. Your looking for a list of compressed tar files. Something like this:

gc6.6.tar.gz 09-Sep-2005 12:04 736K
gc6.7.tar.gz 03-Mar-2006 12:43 738K
gc6.8.tar.gz 12-Jul-2006 17:17 739K

The .gz files will be decompressed with gunzip. You could also download .bz2 files and decompress with bunzip2.

Do not contaminate your computer

I recommend that you pick a local installation directory (as noted below) as opposed to installing packages in the standard system directories.

When you add new files (or replace existing) files in system directories you are effectively contaminating the computer. Programs that used to work may no longer and you may not realize that harm has been not until the trail has grown cold.

The other problem I typically have is that I will build a program and it will work fine, but you never really know why it works (ldd does not show the whole story) So, you distribute to your customers and it does not work because their system library set does not match yours.

Certainly, if you are experimenting, this is the right move.

Also, you do not need sudo or the root password.

Build directory layout

Pick an empty directory in which to download and build all packages.

In addition to a separate build directory for each package add one additional sub-directory to server as the installation point.

Preparing your shell environment

The following assumes that your root build directory is "/home/me/inkscape" and that it has a sub-directory named "install" which will serve as the installation point.

setenv INSTDIR "/home/me/inkscape/install"
setenv CXXFLAGS "-I${INSTDIR}/include"
setenv CPPFLAGS "-I${INSTDIR}/include"
setenv LDFLAGS "-L${INSTDIR}/lib -lm"
setenv LD_LIBRARY_PATH "${INSTDIR}/lib:${LD_LIBRARY_PATH}"
setenv PKG_CONFIG_PATH "${INSTDIR}/lib/pkgconfig"
setenv PATH "${INSTDIR}/bin:${PATH}"

Why do we need these settings?

There are package dependencies. For example, we build pango, cairo and jasper early in the build-order and they will be used to build gtk+ later in the build order.

That explains CXXFLAGS(compilation flags), CPPFLAGS(more compilation flags), LDFLAGS(link flags) and PKG_CONFIG_PATH(used at link time, I guess)

I set PATH because some packages install programs in the ${INSTDIR}/bin directory. These programs are used by later packages to determine version information. Therefore, they must be found along the PATH.

I set LD_LIBRARY_PATH for the same reason. For these programs to run they must find all required libraries, some of which were installed in the ${INSTDIR}/lib directory.

I added the math library "-lm" to LDFLAGS to work around the jasper library idiosyncrasy as noted below.

Which compiler

I used gcc version 3.4.4

How to build a package

The following procedure works in general for all packages, but it specifically does not work for some of them. The exceptions are noted in sections later in this document So, you should not build any packages until you have read this entire document.

Download the compressed tar file to the root directory.

Uncompress the file.

gunzip xyz-1.2.3.tar.gz

De-tar the file. This will create a dedicated sub-directory in which to build the package.

tar xvf xyz-1.2.3.tar

Change to the package directory.

cd xyz-1.2.3

Configure the package.

./configure -prefix ${INSTDIR}

Compile.

make

Install.

make install

Update the shells program cache.

rehash

If you want to rebuild a component you will need to do the following first:

make clean
make distclean

Package idiosyncrasies

Build order and dependencies

The packages must be built and installed in the documented order. ./configure should not complain (and abort) about any dependency violations. See the section on ./configure later in this document.

When building jasper-1.701.0

1: By default, jasper builds to a static library, but packages which use jasper expect a shared build so an additional argument must be added to the ./configure command.

./configure --prefix ${INSTDIR} --enable-shared

2: #The gtk configure script thought that jasper could not be found, but the real problem was that the ./configure test for availability failed to link because it did not include the standard math library "-lm". So, I added -lm to LDFLAGS and then it was happy. The lesson here is to always check the config.log file for the *real* ./configure failure story.

When building libxml2-2.7.6

1: ./configure complains about this at the end, but it does not appear to mean anything significant.

/bin/rm: cannot remove `libtoolT': No such file or directory

When building libxslt-1.1.26

1: lbxslt uses ../install/bin/xml2-config to determine the version of the libxml(2) directory which is available. This is an executable which needs to be found along the PATH. So, the bin subdirectory of the install location has to be added to the PATH. Thus the above "setenv PATH ..."

2: ./configure complains about this at the end, but it does not appear to mean anything significant.

/bin/rm: cannot remove `libtoolT': No such file or directory

3: The libxsl package builds libraries and the program xsltproc I could not get xsltproc to link, but it is not required to build Inkscape, so I edited the Makefile and removed it so that the make would complete. Note: Makefiles are made by ./configure. That is what it does.

When building inkscape-0.47

1: Surprising compilation error in one of the source files.

document.cpp:185: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object

So I hacked line 185 from this:

reinterpret_cast<gpointer>(sp_document_reset_key),

to this:

reinterpret_cast<gpointer>((void*)sp_document_reset_key),

Surviving ./configure

If it tells you that it can't find a dependent package, do not jump to conclusions.

1: Always check the config.log file in cases of failure for the bottom line.

As noted above, when ./configure told me that it could not find the jasper package, a look in the config.log file revealed that the logic used to determine the existence of the jasper package involved building a little test program. That test program failed to link because it could not find symbols like pow and floor. I new these came from the math library and fixed the problem by adding "-lm" to the LDFLAGS environment variable.

2: One time I saw ./configure say this:

gmodule-2.0 >= 2.21.1) were not met

The first time I tried to build Inkscape (6 months ago) it ended in frustration because I could not find the gmodule package anywhere on the web. This time I found that gmodule is actually a library and it is provided by the glib-2.22.3 package.

At the end of the build process the install/lib directory contained 38 library files (*.so), but I only built 23 packages.

The final ldd

Following is the ldd() of the final Inkscape executable. Note that the library versions listed in this table bear no correspondence to the package from which they were built. For example, we built libgtkmm from the package gtkmm-2.18.2, but got the library libgtkmm-2.4.so.1 This just adds to the confusion.

libgtkmm-2.4.so.1
libatkmm-1.6.so.1
libgdkmm-2.4.so.1
libgiomm-2.4.so.1
libpangomm-1.4.so.1
libglibmm-2.4.so.1
libcairomm-1.0.so.1
libgtk-x11-2.0.so.0
libgdk-x11-2.0.so.0
libatk-1.0.so.0
libgio-2.0.so.0
libpangoft2-1.0.so.0
libgdk_pixbuf-2.0.so.0
libpangocairo-1.0.so.0
libpango-1.0.so.0
libfreetype.so.6
libfontconfig.so.1
libgobject-2.0.so.0
libgmodule-2.0.so.0
libxslt.so.1
libz.so.1
libxml2.so.2
libcairo.so.2
libsigc-2.0.so.0
libgthread-2.0.so.0
librt.so.1
libglib-2.0.so.0
libpng12.so.0
libgsl.so.0
libgslcblas.so.0
libm.so.6
libgomp.so.1
libpopt.so.0
libaspell.so.15
libgc.so.1
libstdc++.so.6
libgcc_s.so.1
libpthread.so.0
libc.so.6
libdl.so.2
libX11.so.6
libresolv.so.2
libpixman-1.so.0
libexpat.so.0
libXrender.so.1
libSM.so.6
libICE.so.6
libXinerama.so.1
libXext.so.6

My operating system

>uname -a
Linux juno.adsdesign.analog.com 2.6.9-89.0.9.ELsmp #1 SMP Wed Aug 19 08:06:10 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

>cat /etc/issue
Red Hat Enterprise Linux WS release 4 (Nahant Update 8)
Kernel \r on an \m