diff --git a/src/configure.in b/src/configure.in
index 11fa4cf5ec7b12451374e17f4c10749121a319da..ad75ddd142272bb0bd02f52e3f09359d343d0fc1 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -3692,6 +3692,8 @@ AC_CHECK_LIB(m, floor)
 
 AC_CHECK_LIB(socket, socket)
 
+AC_CHECK_LIB(util, openpty)
+
 if test x"$pike_cv_sys_os" = xWindows_NT ; then
   AC_MSG_CHECKING(if we should use the 64 bit API)
   AC_CACHE_VAL(pike_cv_sys_win64, [
diff --git a/src/modules/_Stdio/configure.in b/src/modules/_Stdio/configure.in
index e81c1f75be09afbe2282dba143017e02209a551f..c047ea2c204c6f21df443f73af0629882a0418af 100644
--- a/src/modules/_Stdio/configure.in
+++ b/src/modules/_Stdio/configure.in
@@ -66,6 +66,8 @@ dnl updated here. This is needed in case the gmp library is not a
 dnl shared library.
 AC_CHECK_LIB(gmp, main)
 
+AC_CHECK_LIB(util, openpty)
+
 AC_HAVE_FUNCS(readdir_r statvfs statfs ustat lseek64 lstat fsync \
  grantpt unlockpt ptsname posix_openpt socketpair writev sendfile munmap \
  openpty \