diff --git a/lib/_autoload.php b/lib/_autoload.php
index 018468b550e5071c1a57bb52df3fe2b73918fc8f..6e6a65c010c94cd294f1ee7a730076735e151d61 100644
--- a/lib/_autoload.php
+++ b/lib/_autoload.php
@@ -9,11 +9,13 @@
  */
 
 // SSP is loaded as a separate project
-if (file_exists(dirname(dirname(__FILE__)).'/vendor/autoload.php')) {
-    require_once dirname(dirname(__FILE__)).'/vendor/autoload.php';
+$libpath = \SimpleSAML\Utils\System::resolvePath(dirname(dirname(__FILE__)).'/vendor/autoload.php'));
+if (file_exists($prjpath) {
+    require_once $prjpath;
 } else {  // SSP is loaded as a library
-    if (file_exists(dirname(dirname(__FILE__)).'/../../autoload.php')) {
-        require_once dirname(dirname(__FILE__)).'/../../autoload.php';
+    $libpath = \SimpleSAML\Utils\System::resolvePath(dirname(dirname(__FILE__)).'/../../autoload.php'));
+    if (file_exists($libpath) {
+        require_once $libpath;
     } else {
         throw new Exception('Unable to load Composer autoloader');
     }