diff --git a/src/srun/opt.c b/src/srun/opt.c
index 3abfedb79bf0d6d4e54585147475e4417215e599..50a7863166298527a6fbe02f65d3c43b877e1769 100644
--- a/src/srun/opt.c
+++ b/src/srun/opt.c
@@ -819,8 +819,9 @@ static void set_options(const int argc, char **argv)
 	};
 	char *opt_string = "+aA:bB:c:C:d:D:e:Eg:Hi:IjJ:kKlL:m:n:N:"
 		"o:Op:P:qQr:Rst:T:uU:vVw:W:x:XZ";
+#ifdef HAVE_PTY_H
 	char *tmp_str;
-
+#endif
 	struct option *optz = spank_option_table_create (long_options);
 
 	if (!optz) {