diff --git a/core/c/jbigi/build_jbigi.sh b/core/c/jbigi/build_jbigi.sh
index 9afd67a54ef36ea9fed424c0a70d9fbc4c529d01..1521392bb0823df92442444ad6bf57e5b2c52d94 100755
--- a/core/c/jbigi/build_jbigi.sh
+++ b/core/c/jbigi/build_jbigi.sh
@@ -39,7 +39,7 @@ SunOS*|OpenBSD*|NetBSD*|*FreeBSD*|Linux*)
             UNIXTYPE="linux"
         fi
         COMPILEFLAGS="-fPIC -Wall $CFLAGS"
-        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
+        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE} -I/usr/local/include"
         LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
         LIBFILE="libjbigi.so";;
 *)
@@ -49,7 +49,7 @@ esac
 
 if [ "$1" = "dynamic" ] ; then
         echo "Building a jbigi lib that is dynamically linked to GMP"
-        LIBPATH="-L.libs"
+        LIBPATH="-L.libs -L/usr/local/lib"
         INCLUDELIBS="-lgmp"
 else
         echo "Building a jbigi lib that is statically linked to GMP"
@@ -59,6 +59,6 @@ fi
 echo "Compiling C code..."
 rm -f jbigi.o $LIBFILE
 $CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
-$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
+$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH || exit 1
 
 exit 0
diff --git a/debian/patches/0002-jbigi-soname.patch b/debian/patches/0002-jbigi-soname.patch
index 81eeeb08179cf82787b913e310b2b4e38f1b56ad..f1522a86b4f1eee8ee5e7f54e9e0f861ba8dd4f2 100644
--- a/debian/patches/0002-jbigi-soname.patch
+++ b/debian/patches/0002-jbigi-soname.patch
@@ -15,8 +15,8 @@ a soname to shut lintian up.
              UNIXTYPE="linux"
          fi
          COMPILEFLAGS="-fPIC -Wall $CFLAGS"
--        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
-+        INCLUDES="-I. -I./jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
+-        INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE} -I/usr/local/include"
++        INCLUDES="-I. -I./jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE} -I/usr/local/include"
          LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
          LIBFILE="libjbigi.so";;
  *)
@@ -26,6 +26,6 @@ a soname to shut lintian up.
  rm -f jbigi.o $LIBFILE
 -$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
 +$CC -c $COMPILEFLAGS $INCLUDES ./jbigi/src/jbigi.c || exit 1
- $CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
+ $CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS $LIBPATH || exit 1
  
  exit 0