question regarding sorting libraries by pkg-config on Linux (Suse SLES 10)

Dan Nicholson dbn.lists at gmail.com
Mon Jun 25 05:36:43 PDT 2012


On Mon, Jun 25, 2012 at 12:57 AM, Kees Dekker <Kees.Dekker at infor.com> wrote:
> Hi,
>
>
>
> Considering the following .pc file:
>
>
>
> prefix=/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/..
>
> exec_prefix=${prefix}
>
> libdir=${exec_prefix}/lib
>
> includedir=${prefix}/include
>
>
>
> Name: OpenSSL
>
> Description: Secure Sockets Layer and cryptography libraries and tools
>
> Version: 1.0.1c
>
> Requires:
>
> Libs: -L${libdir} -lssl -lcrypto
>
> Libs.private: -ldl
>
> Cflags: -I${includedir}
>
>
>
> Why does pkg-config swap the library order?
>
>
>
> PKG_CONFIG_LIBDIR=/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig
> pkg-config --static --libs openssl
>
> -L/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/../lib -lcrypto
> -lssl -ldl
>
>
>
> Verbose output:
>
> PKG_CONFIG_DEBUG_SPEW=1
> PKG_CONFIG_LIBDIR=/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig
> pkg-config --static  --libs openssl
>
> PKG_CONFIG_DEBUG_SPEW variable enabling debug spew
>
> Adding directory '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig'
> from PKG_CONFIG_PATH
>
> Global variable definition 'pc_top_builddir' = '$(top_builddir)'
>
> Option --static seen
>
> Option --libs seen
>
> Error printing enabled by default due to use of --version, --libs, --cflags,
> --libs-only-l, --libs-only-L, --libs-only-other, --cflags-only-I,
> --cflags-only-other or --list. Value of --silence-errors: 0
>
> Error printing enabled
>
> Adding virtual 'pkg-config' package to list of known packages
>
> Scanning directory '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig'
>
> Ignoring file '.' in search directory; not a .pc file
>
> Ignoring file '..' in search directory; not a .pc file
>
> File 'libcrypto.pc' appears to be a .pc file
>
> Will find package 'libcrypto' in file
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig/libcrypto.pc'
>
> File 'libssl.pc' appears to be a .pc file
>
> Will find package 'libssl' in file
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig/libssl.pc'
>
> File 'openssl.pc' appears to be a .pc file
>
> Will find package 'openssl' in file
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig/openssl.pc'
>
> Looking for package 'openssl'
>
> Looking for package 'openssl-uninstalled'
>
> Reading 'openssl' from file
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig/openssl.pc'
>
> Parsing package file
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/lib/pkgconfig/openssl.pc'
>
>   line>prefix=/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/..
>
> Variable declaration, 'prefix' has value
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/..'
>
>   line>exec_prefix=${prefix}
>
> Variable declaration, 'exec_prefix' has value
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/..'
>
>   line>libdir=${exec_prefix}/lib
>
> Variable declaration, 'libdir' has value
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/../lib'
>
>   line>includedir=${prefix}/include
>
> Variable declaration, 'includedir' has value
> '/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/../include'
>
>   line>
>
>   line>Name: OpenSSL
>
>   line>Description: Secure Sockets Layer and cryptography libraries and
> tools
>
>   line>Version: 1.0.1c
>
>   line>Requires:
>
>   line>Libs: -L${libdir} -lssl -lcrypto
>
>   line>Libs.private: -ldl
>
>   line>Cflags: -I${includedir}
>
> Path position of 'OpenSSL' is 1
>
> Adding 'openssl' to list of known packages, returning as package 'openssl'
>
> original:  OpenSSL
>
>  sorted:  OpenSSL
>
>  original:  OpenSSL
>
>  sorted:  OpenSSL
>
> -L/vobs/obj.SUSE10/thirdparty/OpenSSL/32bit/openssl-1.0.1c/../lib -lcrypto
> -lssl -ldl

Yeah, that's a bug. There are some ways pkg-config will reorder
arguments, but from within the same pc file you shouldn't see that.
What version of pkg-config are you using? Is it possible to try the
current release or git master? It should be relatively easy to build
(as long as you have glib around) and then you can just point
pkg-config directly at your file without worrying about the path it's
using.

pkg-config --libs --static /path/to/your/file.pc

--
Dan


More information about the pkg-config mailing list