What version of riscv-tools and riscv-openocd do you have? I see no openpty calls in jimtcl, and the jimtcl/jim-aio.c file has only 1509 lines but you got an error on line 2070.
On a linux/glibc system, openpty is in libutil. But openpty is a function from BSD which is not POSIX so it is odd for code to be using it, unless maybe it was configured for BSD. If you aren’t on a BSD system, then maybe there is a configure problem.
openpty is in libutil.so which is used by jimctl. I saw the error when using gcc 7.2.0 (which is a very old one).
The problem for me was, for reasons unknown, although libutil.so and libutil.a is available inside my /usr/lib64 directory, it cannot be seen/found during the link stage. I believe you are having the same problem
My solution was to add libutil explicitly when running configure, i.e. LDFLAGS=’-L/usr/lib64 ’ LIBS=’-lutil ’ ./configure