Search code examples
autoconfgentoopkg-config

Using library with different names within autoconf


I am trying to build an application with OpenSync 0.4 (0.3.9 indeed) dependency.

In the project's configure.ac the opensync library is written as libopensync1. However, this doesn't build on my Gentoo system. Changing libopensync1 to libopensync does fix the issue for me.

I searched with Google and found that libopensync1 is used in some distributions, while libopensync in others. So how to resolve this issue in configure.ac?

Thanks.


Solution

  • I'm assuming that the place at which this occurs inside your configure.ac is inside a PKG_CHECK_MODULES call.

    Looking at the libopensync sources, it seems that libopensync1 is the newer name, and libopensync is the old name. So, we'll use pkg-config macros to look for the newer name unless it doesn't exist.

    Put this in your configure.ac:

    # Check if libopensync1 is known to pkg-config, and if not, look for libopensync instead
    PKG_CHECK_EXISTS([libopensync1], [OPENSYNC=libopensync1], [OPENSYNC=libopensync])
    

    Then later in your PKG_CHECK_MODULES call, replace libopensync1 with $OPENSYNC.