--- Source/Modules/main.cxx
+++ Source/Modules/main.cxx
@@ -879,6 +879,23 @@
   }
 }
 
+#if defined(HAVE_UNISTD_H)
+#include <libgen.h>
+#include <unistd.h>
+
+static String *get_exe_path(void) {
+    char buffer[PATH_MAX];
+    ssize_t nb = readlink("/proc/self/exe", buffer, PATH_MAX);
+    if (nb != -1) {
+        buffer[nb] = '\0';
+        dirname(buffer);
+        strcat(buffer, "/swiglib");
+        return NewStringWithSize(buffer, strlen(buffer));
+    }
+    return NewString(SWIG_LIB);
+}
+#endif
+
 int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
   char *c;
 
@@ -938,13 +953,15 @@
     char buf[MAX_PATH];
     char *p;
     if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
       *(p + 1) = '\0';
-      SwigLib = NewStringf("%sLib", buf); // Native windows installation path
+      SwigLib = NewStringf("%sswiglib", buf); // Native windows installation path
     } else {
       SwigLib = NewStringf("");	// Unexpected error
     }
     if (Len(SWIG_LIB_WIN_UNIX) > 0)
       SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
+#elif defined(HAVE_UNISTD_H)
+    SwigLib = get_exe_path();
 #else
     SwigLib = NewString(SWIG_LIB);
 #endif
