Undefined link to `forkpty '

So, I am developing my project in Eclipse in Ubuntu 10.04. I have the following lines of code:

#include <pty.h> pid_t pid; int master; pid = forkpty(&master, NULL, NULL, NULL); 

But when I try to build it in Eclipse, I get an error:

 undefined reference to 'forkpty' 

Any idea how to solve this problem?

+8
c ++ linker
source share
3 answers

You need the -lutil command line argument (to use the shared libutil library).
For Eclipse: http://zetcode.com/articles/eclipsecdevelopment/

Select Project Properties. Expand the C / C ++ Build tab. Select settings. On the Tool Options tab, expand the GCC C Linker option. Click on the libraries. Add /usr/lib/libutil.so to the Libraries window. Please note that this path may vary on your system.

+14
source share

This is a communication error; you are missing the util library. Do this to build on the command line:

 g++ myprogram.cpp -lutil 

Eclipse must have project-level options to list the libraries that can be referenced.

+5
source share

I ran into this problem when trying to set a delegate
Therefore, if you try make delegate and receive an error

 undefined reference to `forkpty' 

so edit the _-forkpty.c file inside the maker folder

vim maker/_-forkpty.c and add #include <util.h>

 make clean make 
0
source share

Source: https://habr.com/ru/post/650311/


All Articles