--- a/os-posix.c
+++ b/os-posix.c
@@ -80,6 +80,8 @@ void os_setup_signal_handling(void)
     sigaction(SIGTERM, &act, NULL);
 }
 
+#ifdef find_datadir_dynamic
+
 /* Find a likely location for support files using the location of the binary.
    For installed binaries this will be "$bindir/../share/qemu".  When
    running from the build tree this will be "$bindir/../pc-bios".  */
@@ -143,6 +145,18 @@ char *os_find_datadir(const char *argv0)
 #undef SHARE_SUFFIX
 #undef BUILD_SUFFIX
 
+#else /* !no_find_datadir */
+
+/* for a packaged version we want to ensure data is found in a known place,
+ * which is CONFIG_QEMU_DATADIR. Can be specified on command line
+ * (-L option) */
+char *os_find_datadir(const char *argv0)
+{
+    return NULL;
+}
+
+#endif
+
 void os_set_proc_name(const char *s)
 {
 #if defined(PR_SET_NAME)
