+#if defined(__linux__)
+static void
+find_executable_path (void)
+{
+ GError *error = NULL;
+
+ if (_gst_executable_path)
+ return;
+
+ _gst_executable_path = g_file_read_link ("/proc/self/exe", &error);
+ if (error)
+ g_error_free (error);
+}
+#elif defined(G_OS_WIN32)
+static void
+find_executable_path (void)
+{
+ char buffer[MAX_PATH];
+
+ if (!GetModuleFileName (NULL, buffer, MAX_PATH))
+ return;
+
+ _gst_executable_path = g_strdup (buffer);
+}
+#elif defined(__APPLE__) && !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR && !TARGET_OS_EMBEDDED
+static void
+find_executable_path (void)
+{
+ int ret;
+ pid_t pid;
+ char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
+
+ pid = getpid ();
+ ret = proc_pidpath (pid, pathbuf, sizeof (pathbuf));
+ if (ret > 0)
+ _gst_executable_path = g_strdup (pathbuf);
+}
+#else
+static void
+find_executable_path (void)
+{
+ GST_FIXME ("Couldn't look up executable path, add support for this platform");
+}
+#endif
+
+/**
+ * gst_get_main_executable_path:
+ *
+ * This helper is mostly helpful for plugins that need to
+ * inspect the folder of the main executable to determine
+ * their set of features.
+ *
+ * When a plugin is initialized from the gst-plugin-scanner
+ * external process, the returned path will be the same as from the
+ * parent process.
+ *
+ * Returns: (transfer none) (nullable): The path of the executable that
+ * initialized GStreamer, or %NULL if it could not be determined.
+ *
+ * Since: 1.14
+ */
+const gchar *
+gst_get_main_executable_path (void)
+{
+ return _gst_executable_path;
+}
+