Error in Building riscv-openocd


I am trying to build riscv-openocd (which is the debugger) from the repository . I got below error.

/opt/riscv-tools/riscv-tools/riscv-openocd/build/jimtcl/…/…/jimtcl/jim-aio.c:2070: undefined reference to `openpty’
collect2: error: ld returned 1 exit status
Makefile:2760: recipe for target ‘src/openocd’ failed
make[2]: *** [src/openocd] Error 1
make[2]: Leaving directory ‘/opt/riscv-tools/riscv-tools/riscv-openocd/build’
Makefile:4092: recipe for target ‘all-recursive’ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/opt/riscv-tools/riscv-tools/riscv-openocd/build’
Makefile:1748: recipe for target ‘all’ failed
make: *** [all] Error 2

where is this openpty API located ? in which library?

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 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 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