diff --git a/tools/g-ir-scanner b/tools/g-ir-scanner
index 667a9ac..6eb9e37 100755
--- a/tools/g-ir-scanner
+++ b/tools/g-ir-scanner
@@ -203,6 +203,13 @@ def main(args):
         pkg_options, unused = parser.parse_args(filtered_output)
         options.library_paths.extend(pkg_options.library_paths)
 
+    lpath = os.environ.get('LPATH')
+    library_path = ':'.join(options.library_paths)
+    if lpath:
+        os.environ['LPATH'] = ':'.join([lpath, library_path])
+    else:
+        os.environ['LPATH'] = library_path
+
     filenames = []
     for arg in args:
         if (arg.endswith('.c') or
