【问题标题】:Error compiling with GCC using pty使用 pty 编译 GCC 时出错
【发布时间】:2012-11-13 08:31:13
【问题描述】:

我在用 C 处理 pty,但由于某种原因,代码无法编译

#include <pty.h>
#include <stdlib.h>
#include <stdio.h>

void main(){
    int fd;
    ptyfork(&fd,NULL,NULL,NULL);
}

我用-lutil编译,输出下一个错误:

gcc -lutil test3.c -o test3
/tmp/ccgTfZvt.o: In function 'main':
test3.c:(.text+0x24): undefined reference to `ptyfork'
collect2: ld returned 1 exit status

我错过了什么?

注意:我在 ubuntu 12.04 LTS 64 位中编译

编辑:尝试gcc test3.c -o test3 -lutil 没有成功。

【问题讨论】:

    标签: c linux gcc pty


    【解决方案1】:

    函数是forkpty,而不是ptyfork。请参阅documentation

    【讨论】:

    • @Alejandro Garcia:别担心。使用-Wall 来避免此类问题。使用它,您将在编译期间收到以下消息:implicit declaration of function ptyfork.
    猜你喜欢
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 1970-01-01
    相关资源
    最近更新 更多