0

I tried to compile atk 2.7.91 from source. Since I am working on an older ubuntu system there are no recent packages for the required glib version. So I just downloaded glib 2.35.8 and did successfully ./configure and make for it (I don't want to install it system-wide so I didn't do make install).

Suppose this glib is in /foobar/glib-2.35.8. Now I cd to /foobar/atk-2.7.91 and export the PKG_CONFIG_PATH: export PKG_CONFIG_PATH=/foobar/glib-2.35.8:$PKG_CONFIG_PATH.

Then

pkg-config --modversion glib-2.0

tells me:

2.35.8

But when I do ./configure I get the error message:

checking for GLIB - version >= 2.31.2... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error: 
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** but not in the same location as pkg-config add the location of the file
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.

cat config.log |grep glib gives:

configure:12143: checking for GLIB - version >= 2.31.2
configure:12258: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include    -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES  conftest.c -L/usr/local/lib -lgobject-2.0 -lglib-2.0    >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
|   fclose (fopen ("conf.glibtest", "w"));
|   if ((glib_major_version != 2) ||
|       (glib_minor_version != 35) ||
|       (glib_micro_version != 8))
|       printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
|              glib_major_version, glib_minor_version, glib_micro_version);
|       printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
|   else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
|      (glib_minor_version != GLIB_MINOR_VERSION) ||
|            (glib_micro_version != GLIB_MICRO_VERSION))
|       printf("*** GLIB header files (version %d.%d.%d) do not match\n",
|        GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
|        glib_major_version, glib_minor_version, glib_micro_version);
|       if ((glib_major_version > major) ||
|         ((glib_major_version == major) && (glib_minor_version > minor)) ||
|         ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
|         printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n",
|                glib_major_version, glib_minor_version, glib_micro_version);
|         printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n",
|         printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
|         printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
configure:12304: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include    -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES  conftest.c  -L/usr/local/lib -lgobject-2.0 -lglib-2.0   >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
|  return ((glib_major_version) || (glib_minor_version) || (glib_micro_version));
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.
ac_cv_env_PKG_CONFIG_PATH_value=/foobar/glib-2.35.8/:
GLIB_CFLAGS=''
GLIB_COMPILE_RESOURCES=''
GLIB_GENMARSHAL=''
GLIB_LIBS=''
GLIB_MKENUMS=''
GLIB_PACKAGES='gobject-2.0'
GLIB_REQUIRED_VERSION='2.31.2'
PKG_CONFIG_PATH='/foobar/glib-2.35.8/:'

Any idea what's wrong here and how to fix it?

romaninsh
  • 10,606
  • 4
  • 50
  • 70
student
  • 1,636
  • 3
  • 29
  • 53

2 Answers2

3

SHORT ANSWER

As (almost) always the Manual is your friend. Try taking a look at man pkg-config you'll see it's the .pc files that pkg-config needs to perform it's job. glib-2.0.pc in your case. Unfortunately it's not as easy as just pointing to the location, where it is stored, but leave that for the long answer at the end and take a look at the manual page for a while first.

pkg-config retrieves information about packages from special metadata files. These files are named after the package, and has a .pc extension. On most systems, pkg-config looks in and for these files. It will additionally look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment variable.

The package name specified on the pkg-config command line is defined to be the name of the metadata file, minus the .pc extension. If a library can install multiple versions simultaneously, it must give each version its own name (for example, GTK 1.2 might have the package name "gtk+" while GTK 2.0 has "gtk+-2.0").

I hope you found the funny

On most systems, pkg-config looks in and for these files

line. The result may differ on yours system, but on mine it actually displays it that way, which is most probably a bug.

Nevertheless you can find out the compiled in standard directories by running pkg-config --variable pc_path pkg-config which for example prints

/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/i486-linux-gnu:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib/pkgconfig/i486-linux-gnu:/usr/share/pkgconfig

on my system.

LONG ANSWER

To get back to your original question, taking a look at an example .pc file might best explain why your first effort was in vain. As an example here the contents of the glib-2.0.pc file on my system:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 2.24.2
Libs: -L${libdir} -lglib-2.0 
Libs.private: 
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include 

As you will hopefully see the whole pathes are all hardwired. Don't get confused by ${libdir} ... and the like. Taking a closer look you will see they are all constructed from prefix=/usr in the first line.

The reason trying to just point PKG_CONFIG_PATH to the build directory of your glib won't work as the path specified in the .pc ist the installation directory and not the location of your build directory.

That's why your pkg-config --modversion test ran just fine: The .pc file was indeed found and contained the given information, but the compilation failed: the .pc file was found as in the first case, but the pathes given in the .pc file were simply wrong.

No one can forbid you to just change the directories given in the .pc to any path you like, so in fact you could make the fresh built library work in its build directory by manually fixing the pathes given in the .pc file. At least if the library itself doesn't contain any hardwired pathes, but that would only be a problem at runtime not while linking.

To even solve the last puzzle - how the the hell could the .pc file know where it is going to be installed to give the right prefix? Just take a look at your source directory. Acompanying your glib-2.0.pc file you'll find a file called glib-2.0.pc.in there, with content like that given below:

prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: @VERSION@
Requires.private: @PCRE_REQUIRES@
Libs: -L${libdir} -lglib-2.0 @INTLLIBS@
Libs.private: @G_THREAD_LIBS@ @G_LIBS_EXTRA@ @PCRE_LIBS@ @INTLLIBS@ @ICONV_LIBS@
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include @GLIB_EXTRA_CFLAGS@

The whole @....@ placeholders where filled in at configure time, when you were running configure. i.e. @prefix@ was filled with the argument given as --prefix= on the command line, while others like @NTLLIBS@ were filled with parameters detected by the configure script.

mikyra
  • 10,077
  • 1
  • 40
  • 41
2

You need to install the glib somewhere, you can't just point ATK at the Glib build directory. You can install it somewhere private like ~/install by

./configure --prefix=/home/<username>/install

(configure doesn't like ~ IIRC)

iain
  • 5,660
  • 1
  • 30
  • 51
  • Thanks. After doing this I did `export PKG_CONFIG_PATH=/home//install/glib/lib/pkgconfig/` and also `export LD_LIBRARY_PATH=/home//build/glib/lib` and it worked. But I don't really understand, why for example `export PKG_CONFIG_PATH=/home//install/glib/lib/` doesn't work. Do you have any reference for a good resource to learn those things? – student Feb 21 '13 at 19:48