ubuntu20.04使用openpty时链接lutil库失败
发表于 : 2022-06-08 14:36
源代码如下:
#include <stddef.h>
#include <stdio.h>
#include <pty.h>
int main(void)
{
int iRet;
int iMaster;
int iSlave;
iRet = openpty(&iMaster, &iSlave, NULL, NULL, NULL);
if (0 != iRet)
{
printf("failed to open pty.\n");
return -1;
}
return 0;
}
编译报链接错误:
gcc -Wall -lutil -o test test.c
/usr/bin/ld: /tmp/ccNbau8Y.o: in function `main':
test.c:(.text+0x37): undefined reference to `openpty'
collect2: error: ld returned 1 exit status
同样代码在centos 7.1编译通过,gcc glibc版本使用更高的,也可以编译通过;
手动指定ltuil的位置,以及手动重编glibc库,再重新指定,也无法编译通过,各位谁有经验处理过类似问题的,请不吝赐教,谢谢~
系统版本:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
#include <stddef.h>
#include <stdio.h>
#include <pty.h>
int main(void)
{
int iRet;
int iMaster;
int iSlave;
iRet = openpty(&iMaster, &iSlave, NULL, NULL, NULL);
if (0 != iRet)
{
printf("failed to open pty.\n");
return -1;
}
return 0;
}
编译报链接错误:
gcc -Wall -lutil -o test test.c
/usr/bin/ld: /tmp/ccNbau8Y.o: in function `main':
test.c:(.text+0x37): undefined reference to `openpty'
collect2: error: ld returned 1 exit status
同样代码在centos 7.1编译通过,gcc glibc版本使用更高的,也可以编译通过;
手动指定ltuil的位置,以及手动重编glibc库,再重新指定,也无法编译通过,各位谁有经验处理过类似问题的,请不吝赐教,谢谢~
系统版本:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal