diff --git a/gb.httpd/src/libhttpd.c b/gb.httpd/src/libhttpd.c
index 4ecec5a..f42946d 100644
--- a/gb.httpd/src/libhttpd.c
+++ b/gb.httpd/src/libhttpd.c
@@ -97,9 +97,11 @@ extern char *crypt(const char *key, const char *setting);
 #define SHUT_WR 1
 #endif
 
+#ifndef __HAIKU__
 #ifndef HAVE_INT64T
 typedef long long int64_t;
 #endif
+#endif
 
 #ifndef HAVE_SOCKLENT
 typedef int socklen_t;
diff --git a/gb.httpd/src/thttpd.c b/gb.httpd/src/thttpd.c
index ac80813..44371e9 100644
--- a/gb.httpd/src/thttpd.c
+++ b/gb.httpd/src/thttpd.c
@@ -64,10 +64,11 @@
 #define SHUT_WR 1
 #endif
 
+#ifndef __HAIKU__
 #ifndef HAVE_INT64T
 typedef long long int64_t;
 #endif
-
+#endif
 
 static char *argv0;
 static bool _debug;
diff --git a/gb.net/src/CSerialPort.c b/gb.net/src/CSerialPort.c
index 1ce84bc..6c6767e 100644
--- a/gb.net/src/CSerialPort.c
+++ b/gb.net/src/CSerialPort.c
@@ -82,7 +82,9 @@ static SERIAL_SIGNAL get_signals(CSERIALPORT *_object)
 	signals.RTS = (ist & TIOCM_RTS) != 0;
 	signals.CTS = (ist & TIOCM_CTS) != 0;
 	signals.DCD = (ist & TIOCM_CAR) != 0;
+#ifndef __HAIKU__
 	signals.RNG = (ist & TIOCM_RNG) != 0;
+#endif
 
 	return signals;
 }
@@ -668,13 +670,13 @@ END_PROPERTY
 BEGIN_PROPERTY(SerialPort_OutputBufferSize)
 
 	int ret = 0;
-
+#ifndef __HAIKU__
 	if (THIS->status)
 	{
 		if (ioctl(THIS->port, TIOCOUTQ, &ret))
 			GB.Error("Unable to read output buffer size: &1", strerror(errno));
 	}
-
+#endif
 	GB.ReturnInteger(ret);
 
 END_PROPERTY
diff --git a/gb.xml/src/element.cpp b/gb.xml/src/element.cpp
index 51b119c..3eda142 100644
--- a/gb.xml/src/element.cpp
+++ b/gb.xml/src/element.cpp
@@ -28,6 +28,11 @@
 #include <stdlib.h>
 #include <memory.h>
 
+#if defined(__HAIKU__)
+#include <string.h>
+void *memrchr(const char *s, int c, size_t n);
+#endif
+
 /*************************************** Element ***************************************/
 
 Element* XMLElement_New()
diff --git a/gb.xml/src/gb.xml.h b/gb.xml/src/gb.xml.h
index 8f8566a..3c30c11 100644
--- a/gb.xml/src/gb.xml.h
+++ b/gb.xml/src/gb.xml.h
@@ -192,7 +192,7 @@ typedef struct
 
     void (*ThrowXMLParseException)(const char* nerror, const char *text, const size_t lenText, const char *posFailed);
 
-#if defined(OS_MACOSX) || defined(__APPLE__)
+#if defined(OS_MACOSX) || defined(__APPLE__) || defined(__HAIKU__)
     void* (*memrchr)(const char *s, int c, size_t n);
 #endif
 
diff --git a/gb.xml/src/html/cssfilter.cpp b/gb.xml/src/html/cssfilter.cpp
index 35c856f..4d55ee0 100644
--- a/gb.xml/src/html/cssfilter.cpp
+++ b/gb.xml/src/html/cssfilter.cpp
@@ -3,6 +3,23 @@
 #include "htmlelement.h"
 #include <memory.h>
 
+#if defined(__HAIKU__)
+static void *memrchr(const char *s, int c, size_t n)
+{
+    const char *start=s,*end=(s+n-1);
+
+    while(end>=start)
+    {
+        if(*end==c)
+            return (void *)end;
+        else
+            end--;
+    }
+
+    return NULL;
+}
+#endif
+
 bool HTMLElement_MatchSubFilter(const Element *elmt, const char *filter, size_t lenFilter);
 
 bool HTMLElement_MatchFilter(const Element *elmt, const char *filter, size_t lenFilter)
diff --git a/gb.xml/src/main.cpp b/gb.xml/src/main.cpp
index 56f8fbf..1383f45 100644
--- a/gb.xml/src/main.cpp
+++ b/gb.xml/src/main.cpp
@@ -36,6 +36,23 @@
 #include "gambas.h"
 #include "html/gb.xml.html.h"
 
+#if defined(__HAIKU__)
+static void *memrchr(const char *s, int c, size_t n)
+{
+    const char *start=s,*end=(s+n-1);
+
+    while(end>=start)
+    {
+        if(*end==c)
+            return (void *)end;
+        else
+            end--;
+    }
+
+    return NULL;
+}
+#endif
+
 GB_INTERFACE GB EXPORT;
 XML_HTML_INTERFACE HTML EXPORT;
 
@@ -104,7 +121,7 @@ extern "C"
 
         (void *)ThrowXMLParseException,
 
-    #if defined(OS_MACOSX) || defined(__APPLE__)
+    #if defined(OS_MACOSX) || defined(__APPLE__) || defined(__HAIKU__)
         (void*)memrchr,
     #endif
 
diff --git a/gb.xml/src/utils.cpp b/gb.xml/src/utils.cpp
index e57ac2a..712af02 100644
--- a/gb.xml/src/utils.cpp
+++ b/gb.xml/src/utils.cpp
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <memory.h>
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(__HAIKU__)
 void *memrchr(const char *s, int c, size_t n)
 {
     const char *start=s,*end=(s+n-1);
diff --git a/main/configure.ac b/main/configure.ac
index c05df71..650caf5 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -98,7 +98,7 @@ GB_COMPONENT(
 dnl ---- We do not use libtool to load shared libraries anymore!
 
 AC_DEFINE(DONT_USE_LTDL, 1, [Do not use libtool to load shared libraries])
-if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD" && test "$SYSTEM" != "NETBSD"; then
+if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD" && test "$SYSTEM" != "HAIKU" && test "$SYSTEM" != "NETBSD"; then
   DL_LIB="-ldl"
 else
   DL_LIB=""
diff --git a/main/gbx/gbx_c_application.c b/main/gbx/gbx_c_application.c
index 2e5ec4f..0046c7f 100644
--- a/main/gbx/gbx_c_application.c
+++ b/main/gbx/gbx_c_application.c
@@ -283,7 +283,7 @@ static void init_again(int old_pid)
 }
 
 BEGIN_PROPERTY(Application_Daemon)
-
+#ifndef __HAIKU__
 	int old_pid;
 
 	if (READ_PROPERTY)
@@ -300,7 +300,7 @@ BEGIN_PROPERTY(Application_Daemon)
 			init_again(old_pid);
 		}
 	}
-
+#endif
 END_PROPERTY
 
 
diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c
index eda566b..6f5ae46 100644
--- a/main/gbx/gbx_c_file.c
+++ b/main/gbx/gbx_c_file.c
@@ -32,11 +32,15 @@
 #include <grp.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#ifdef OS_BSD
+#if defined(OS_BSD) || defined(__HAIKU__)
 	#include <sys/types.h>
 #else
 	#include <sys/sysmacros.h>
 #endif
+#ifdef __HAIKU__
+#define major(dev) ((int)(((unsigned int) (dev) >> 8) & 0xff))
+#define minor(dev) ((int)((dev) & 0xff))
+#endif
 #include <termios.h>
 
 #include "gb_common.h"
diff --git a/main/lib/signal/csignal.c b/main/lib/signal/csignal.c
index 5ce5c6c..20ea890 100644
--- a/main/lib/signal/csignal.c
+++ b/main/lib/signal/csignal.c
@@ -221,7 +221,9 @@ GB_DESC CSignalDesc[] =
 	GB_CONSTANT("SIGILL", "i", SIGILL),
 	GB_CONSTANT("SIGTRAP", "i", SIGTRAP),
 	GB_CONSTANT("SIGABRT", "i", SIGABRT),
+#ifndef __HAIKU__
 	GB_CONSTANT("SIGIOT", "i", SIGIOT),
+#endif
 	GB_CONSTANT("SIGBUS", "i", SIGBUS),
 	GB_CONSTANT("SIGFPE", "i", SIGFPE),
 	GB_CONSTANT("SIGKILL", "i", SIGKILL),
@@ -246,7 +248,9 @@ GB_DESC CSignalDesc[] =
 	GB_CONSTANT("SIGPROF", "i", SIGPROF),
 	GB_CONSTANT("SIGWINCH", "i", SIGWINCH),
 	GB_CONSTANT("SIGPOLL", "i", SIGPOLL),
+#ifndef __HAIKU__
 	GB_CONSTANT("SIGIO", "i", SIGIO),
+#endif
 	GB_CONSTANT("SIGPWR", "i", SIGPWR),
 	GB_CONSTANT("SIGSYS", "i", SIGSYS),
 
diff --git a/main/lib/term/cterm.c b/main/lib/term/cterm.c
index 5567648..e13f5b1 100644
--- a/main/lib/term/cterm.c
+++ b/main/lib/term/cterm.c
@@ -219,22 +219,30 @@ IMPLEMENT_TSP(ECHOPRT, c_lflag)
 IMPLEMENT_TSP(PENDIN, c_lflag)
 #endif
 
+#ifndef __HAIKU__
 IMPLEMENT_TSP_C(VDISCARD)
+#endif
 IMPLEMENT_TSP_C(VEOF)
 IMPLEMENT_TSP_C(VEOL)
 IMPLEMENT_TSP_C(VEOL2)
 IMPLEMENT_TSP_C(VERASE)
 IMPLEMENT_TSP_C(VINTR)
 IMPLEMENT_TSP_C(VKILL)
+#ifndef __HAIKU__
 IMPLEMENT_TSP_C(VLNEXT)
+#endif
 IMPLEMENT_TSP_C(VMIN)
 IMPLEMENT_TSP_C(VQUIT)
+#ifndef __HAIKU__
 IMPLEMENT_TSP_C(VREPRINT)
+#endif
 IMPLEMENT_TSP_C(VSTART)
 IMPLEMENT_TSP_C(VSTOP)
 IMPLEMENT_TSP_C(VSUSP)
 IMPLEMENT_TSP_C(VTIME)
+#ifndef __HAIKU__
 IMPLEMENT_TSP_C(VWERASE)
+#endif
 
 BEGIN_PROPERTY(TerminalSettings_InputSpeed)
 
@@ -348,7 +356,7 @@ GB_DESC TermDesc[] =
 	
 	__TC(B0), __TC(B50), __TC(B75), __TC(B110), __TC(B134), __TC(B150), __TC(B200), __TC(B300), __TC(B600), __TC(B1200), __TC(B1800), __TC(B2400), __TC(B4800), __TC(B9600), __TC(B19200), __TC(B38400), __TC(B57600), __TC(B115200), __TC(B230400),
 
-#ifndef OS_BSD
+#if !defined(OS_BSD) && !defined(__HAIKU__)
  __TC(B460800), __TC(B500000), __TC(B576000), __TC(B921600), __TC(B1000000), __TC(B1152000), __TC(B1500000), __TC(B2000000), __TC(B2500000), __TC(B3000000),
 #endif
 #ifdef OS_LINUX
@@ -430,23 +438,30 @@ GB_DESC TerminalSettingsDesc[] =
 	__TSP(ECHOPRT),
 	__TSP(PENDIN),
 #endif
-
+#ifndef __HAIKU__
 	__TSP_I(VDISCARD),
+#endif
 	__TSP_I(VEOF),
 	__TSP_I(VEOL),
 	__TSP_I(VEOL2),
 	__TSP_I(VERASE),
 	__TSP_I(VINTR),
 	__TSP_I(VKILL),
+#ifndef __HAIKU__
 	__TSP_I(VLNEXT),
+#endif
 	__TSP_I(VMIN),
 	__TSP_I(VQUIT),
+#ifndef __HAIKU__
 	__TSP_I(VREPRINT),
+#endif
 	__TSP_I(VSTART),
 	__TSP_I(VSTOP),
 	__TSP_I(VSUSP),
 	__TSP_I(VTIME),
+#ifndef __HAIKU__
 	__TSP_I(VWERASE),
+#endif
 	
 	GB_PROPERTY("InputSpeed", "i", TerminalSettings_InputSpeed),
 	GB_PROPERTY("OutputSpeed", "i", TerminalSettings_OutputSpeed),
