2

I'm working on a piece of software that needs to compile against a very modern version of glib, but also needs to run on Ubuntu 11.10 (which doesn't come with that version). My first thought was to just backport and replace glib, since the versions are theoretically compatible, but it causes some problems (most noticably with Unity not working right).

I know that the obvious solution is to use Ubuntu 12.04, but I don't have that option right now (working on it though).

Is there any sane way to handle this? Right now I'm looking at just compiling glib, taring it, and then manually setting C_INCLUDE_PATH and LD_LIBRARY_PATH. Unfortunately, I don't think I can't even package the compiled library because glib isn't very specific about its version (it's just glib-2.0.so).

Is the tar method the best I can do in this situation?

Brendan Long
  • 542
  • 4
  • 16

2 Answers2

1

I would suggest installing the new version of glib under /usr/local/lib or /usr/local/lib64 and then utilizing the LD_LIBRARY_PATH environment variable, like you mentioned above.

In fact that appears to be the default location. From the output of ./configure --help in glib-2.33.8:

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

See this Ubuntu Forum thread for more details.

skohrs
  • 572
  • 3
  • 13
0

I had also similar problem, where I needed to compile the ModemManager, which needs a new version of GLib-2 on the OS where this version of GLib-2 is not available via package manager (Ubuntu 18.04). I also did not want to break window manager (which I assumed has some dependencies on the glib-2).

The steps to compile with a newest version of GLib-2 which worked for me:

  1. Compile glib from source (2022, June 2 it is hosted here: https://gitlab.gnome.org/GNOME/glib/). Recent versions use meson build system (so you need to install meson first if you do not have it), and the compilation goes:
meson build
cd build
meson compile
  1. Install glib to some local folder using meson (different from the default location as it will overwrite existing GLib-2 files):
meson install --destdir /local/path/to/where/you/want/GLib-2/to/be/installed

I will use the /local/path/to/where/you/want/GLib-2/to/be/installed as ${install_dir} below, but in the commands you need to substitute the ${install_dir} with your path.

  1. Modify the *.pc PACKAGE_CONFIG files of the custom installation of GLib-2, in the ${install_dir}/usr/local/lib/x86_64-linux-gnu/pkgconfig directory:
gio-2.0.pc
gio-unix-2.0.pc
glib-2.0.pc
gmodule-2.0.pc
gmodule-export-2.0.pc
gmodule-no-export-2.0.pc
gobject-2.0.pc
gthread-2.0.pc

Each of the file starts with a prefix:

prefix=/usr/local

which one needs to replace with the locally installed prefix:

prefix=${install_dir}/usr/local

Finally, invoke the configuration step of the ModemManager as follows:

PGK_CONFIG=${install_dir}/usr/local/lib/x86_64-linux-gnu/pkgconfig meson build

This way I was able to compile the ModemManager with a newer version of GLib-2 than the OS provides.

selyunin
  • 101
  • 2