From 041f680f85cd6ef6b92fe5b33b7bdf249b1a8a53 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 May 2014 09:04:00 +1000 Subject: [PATCH] If a package can't be found, print the search path too Probably the most common issue for a package not being found after installing a library is the PKG_CONFIG_PATH being mixed up. Printing the search path makes debugging that a lot easier. Freedesktop #79032 (https://bugs.freedesktop.org/show_bug.cgi?id=79032) --- pkg.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg.c b/pkg.c index 3697fec..3ba8e27 100644 --- a/pkg.c +++ b/pkg.c @@ -307,10 +307,25 @@ internal_get_package (const char *name, gboolean warn) if (location == NULL) { if (warn) - verbose_error ("Package %s was not found in the pkg-config search path.\n" + { + gchar directories[PATH_MAX * 2] = {0}; /* random guess for size */ + gint len = 0; + GList *dirs; + + dirs = g_list_first (search_dirs); + while (dirs && len < sizeof (directories)) + { + len += g_snprintf (&directories[len], sizeof (directories) - len, + " %s\n", (char*)dirs->data); + dirs = g_list_next (dirs); + } + + verbose_error ("Package %s was not found in the pkg-config search path:\n" + "%s\n" "Perhaps you should add the directory containing `%s.pc'\n" "to the PKG_CONFIG_PATH environment variable\n", - name, name); + name, directories, name); + } return NULL; } -- 1.9.0