diff --git a/src/dlload.c b/src/dlload.c
index 08bd8f91b4bce3..eec3c792a73468 100644
--- a/src/dlload.c
+++ b/src/dlload.c
@@ -207,3 +207,41 @@ char *jl_dlfind_win32(char *f_name)
     // appropriate error.
 }
 #endif
+
+static char* libjulia_path = NULL;
+DLLEXPORT char *jl_get_libjulia_path()
+{
+    if(libjulia_path != NULL)
+    {
+        int max_path = 512;
+        libjulia_path = malloc(max_path);
+
+#ifdef _OS_WINDOWS_
+
+        HMODULE hm = NULL;
+
+        if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+                GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+                (LPCSTR) &jl_get_libjulia_path,
+                &hm))
+        {
+            int ret = GetLastError();
+            fprintf(stderr, "GetModuleHandle returned %d\n", ret);
+        }
+        GetModuleFileNameA(hm, libjulia_path, max_path);
+#else
+        Dl_info dl_info;
+        dladdr((void *)jl_get_libjulia_path, &dl_info);
+        strncpy(libjulia_path, dl_info.dli_fname, max_path);
+#endif
+
+        // remove libjulia.so/dll/dylib from full path
+        char * pos = strrchr(libjulia_path, PATHSEP);
+        if (pos)
+        { // terminate string
+          pos[1] = '\0';
+        }
+      }
+
+    return libjulia_path;
+}
diff --git a/src/julia.h b/src/julia.h
index 05093ed600bcd4..9ac36908b3d626 100644
--- a/src/julia.h
+++ b/src/julia.h
@@ -965,6 +965,7 @@ DLLEXPORT uv_lib_t *jl_wrap_raw_dl_handle(void *handle);
 void *jl_dlsym_e(uv_lib_t *handle, char *symbol); //supress errors
 char *jl_dlfind_win32(char *name);
 DLLEXPORT int add_library_mapping(char *lib, void *hnd);
+DLLEXPORT char *jl_get_libjulia_path();
 
 // event loop
 DLLEXPORT void jl_runEventLoop();