diff --git a/configure.in b/configure.in
index d9d28ff..4fcbe7c 100644
--- libreoffice-3.5.0/configure.in
+++ libreoffice-3.5.0/configure.in
@@ -6474,8 +6474,9 @@ if test -n "$with_system_lpsolve" -o -n "$with_system_libs" && \
     # some systems need this. Like Ubuntu....
     AC_CHECK_LIB(m, floor)
     AC_CHECK_LIB(dl, dlopen)
+    AC_CHECK_LIB(colamd, colamd)
     AC_CHECK_LIB(lpsolve55, make_lp, ,
-        [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
+        [ AC_MSG_ERROR(lpsolve library not found or too old.)], [-L/usr/lib/lpsolve])
     MINGW_EXTERNAL_DLLS="$MINGW_EXTERNAL_DLLS lpsolve55.dll"
 else
     AC_MSG_RESULT([internal])
diff --git a/solenv/inc/libs.mk b/solenv/inc/libs.mk
index 91161f1..eb9885e 100644
--- libreoffice-3.5.0/solenv/inc/libs.mk
+++ libreoffice-3.5.0/solenv/inc/libs.mk
@@ -305,7 +305,13 @@ MYTHESLIB=$(MYTHES_LIBS)
 MYTHESLIB=-lmythes-1.2
 .ENDIF
 PYUNOLIB=-lpyuno
+.IF "$(SYSTEM_LPSOLVE)" == "YES"
+# FIXME. Even with -L/usr/lib/lp_solve -llpsolve55 the liblpsolve55.a from
+# /usr/lib gets picked and we get a static link...
+LPSOLVELIB = /usr/lib/lp_solve/liblpsolve55.so -Wl,-rpath=/usr/lib/lp_solve
+.ELSE
 LPSOLVELIB=-llpsolve55
+.ENDIF
 SOFFICELIB=-lsofficeapp
 UNOPKGAPPLIB=-lunopkgapp
 TESTLIB=-ltest
diff --git a/sccomp/Library_solver.mk b/sccomp/Library_solver.mk
index ba9493a..93874b4 100644
--- libreoffice-3.5.0/sccomp/Library_solver.mk
+++ libreoffice-3.5.0/sccomp/Library_solver.mk
@@ -49,7 +49,13 @@
 	$(gb_STDLIBS) \
 ))
 
+ifeq ($(SYSTEM_LPSOLVE),YES)
+$(eval $(call gb_Library_add_ldflags,solver, \
+	/usr/lib/lp_solve/liblpsolve55.so -Wl$(COMMA)-rpath=/usr/lib/lp_solve \
+))
+else
 $(eval $(call gb_Library_use_external,solver,lpsolve55))
+endif
 
 $(eval $(call gb_Library_add_exception_objects,solver,\
 	sccomp/source/solver/solver \
