# libutil.so.5 not found while Tty.so asks for it



## swaprava (Apr 29, 2009)

I'm trying to run a perl script on FreeBSD. This script tries to access libutil.so.5, while I have libutil.so.7 linked from libutil.so in 

/usr/lib/ . The error shown is as follows:

```
Can't load '/usr/local/lib/perl5/site_perl/5.8.8/mach/auto/IO/Tty/Tty.so' for module IO::Tty: Shared object "libutil.so.5" not found, 

required by "Tty.so" at /usr/local/lib/perl5/5.8.8/mach/DynaLoader.pm line 230
```
DynaLoader line 230 is as follows:


```
# Many dynamic extension loading problems will appear to come from
    # this section of code: XYZ failed at line 123 of DynaLoader.pm.
    # Often these errors are actually occurring in the initialisation
    # C code of the extension XS file. Perl reports the error as being
    # in this perl code simply because this was the last perl code
    # it executed.

    my $libref = dl_load_file($file, $module->dl_load_flags) or
        croak("Can't load '$file' for module $module: ".dl_error());
```
I have tried the following things, which didn't prove to be useful:

1. Created a new libutil.so.5 in /usr/lib/ and linked it to libutil.so.5 -> /lib/libutil.so, where already libutil.so -> /lib/libutil.so.7 is 

there. This didn't work.
2. Reinstalled perl modules several times and that too didn't work.
3. Installed the latest perl version perl5.10.0 and ran the perl script with this version, problem was still there.

Can you please advise what should I do to alleviate this problem? I don't know how to install the libutils port. So, couldn't try that out. 

Since this file is asked by the Tty.so, which can't be edited using text editor, is there any other way so that it asks for libutil.so.7 

instead of 5?

The script that I was trying to run is the following: it basically tries to reboot the router connected to the serial port of the FreeBSD 

machine.


```
#!/usr/bin/perl
########################################################################
use V6evalRemote;

rOpen() || goto error;		<--- MY GUESS IS THIS SCRIPT FAILS IN rOpen() FUNCTION ITSELF

rArg();

#rDebug(1);

$rOpt_timeout = 300 if ! defined($rOpt_timeout);

rLogin(5) || goto error;

rCommand("term len 0", $rOpt_timeout) || goto error;
rCommand("show version", $rOpt_timeout) || goto error;
rCommand("show startup-config", $rOpt_timeout) || goto error;
rCommand("show align", $rOpt_timeout) || goto error;

rCommand("configure terminal", $rOpt_timeout) || goto error;
rCommand("no ipv6 unicast", $rOpt_timeout) || goto error;
rCommand("ipv6 unicast", $rOpt_timeout) || goto error;
rCommand("end", $rOpt_timeout) || goto error;

rReboot($rOpt_timeout) || goto error;

rClose();
exit($V6evalRemote::exitPass);

error:
    rClose();
    exit($V6evalRemote::exitFail);

########################################################################
```


----------



## gordon@ (Apr 29, 2009)

Where did you get the IO::Tty module?


----------



## SirDice (Apr 29, 2009)

Hopefully it's devel/p5-IO-Tty. Remove that port (and that symlink you created) and rebuild using the port. Don't use a package. Or install misc/compat5x. Libutil.so.5 is part of FreeBSD 5, you seem to have 7.


----------



## swaprava (Apr 30, 2009)

gordon@ said:
			
		

> Where did you get the IO::Tty module?



yes, I got it in /usr/ports/devel/p5-IO-Tty


----------



## swaprava (Apr 30, 2009)

SirDice said:
			
		

> Hopefully it's devel/p5-IO-Tty. Remove that port (and that symlink you created) and rebuild using the port. Don't use a package. Or install misc/compat5x. Libutil.so.5 is part of FreeBSD 5, you seem to have 7.



I added the FORCE_PKG_REGISTER=1 line in the Makefile in /usr/ports/devel/p5-IO-Tty


```
PORTNAME=       IO-Tty
PORTVERSION=    1.07
CATEGORIES=     devel perl5
MASTER_SITES=   CPAN
PKGNAMEPREFIX=  p5-
FORCE_PKG_REGISTER=1
```
 
and did make install clean

Please see the following logs during installation:


```
[root@swaprava /usr/ports/devel/p5-IO-Tty]# make install clean
===>  Installing for p5-IO-Tty-1.07
===>   p5-IO-Tty-1.07 depends on file: /usr/local/bin/perl5.8.8 - found
===>   Generating temporary packing list
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Tty::Constant.3
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Tty.3
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Pty.3
Writing /usr/local/lib/perl5/site_perl/5.8.8/mach/auto/IO/Tty/.packlist
===>   Compressing manual pages for p5-IO-Tty-1.07
===>   Registering installation for p5-IO-Tty-1.07
===>  Cleaning for p5-IO-Tty-1.07
[root@swaprava /usr/ports/devel/p5-IO-Tty]# make install clean
===>  Vulnerability check disabled, database not found
===>  Extracting for p5-IO-Tty-1.07
=> MD5 Checksum OK for IO-Tty-1.07.tar.gz.
=> SHA256 Checksum OK for IO-Tty-1.07.tar.gz.
===>   p5-IO-Tty-1.07 depends on file: /usr/local/bin/perl5.8.8 - found
===>  Patching for p5-IO-Tty-1.07
===>   p5-IO-Tty-1.07 depends on file: /usr/local/bin/perl5.8.8 - found
===>   p5-IO-Tty-1.07 depends on file: /usr/local/bin/perl5.8.8 - found
===>  Configuring for p5-IO-Tty-1.07
Now let's see what we can find out about your system
(logfiles of failing tests are available in the conf/ dir)...
Looking for _getpty()...... not found.
Looking for getpt()........ not found.
Looking for grantpt()...... FOUND.
Looking for openpty()...... FOUND.
Looking for ptsname()...... FOUND.
Looking for ptsname_r().... not found.
Looking for sigaction().... FOUND.
Looking for strlcpy()...... FOUND.
Looking for ttyname()...... FOUND.
Looking for unlockpt()..... FOUND.
Looking for libutil.h...... FOUND.
Looking for pty.h.......... not found.
Looking for sys/pty.h...... not found.
Looking for sys/ptyio.h.... not found.
Looking for sys/stropts.h.. not found.
Looking for termio.h....... not found.
Looking for termios.h...... FOUND.
Looking for util.h......... not found.
Checking which symbols compile OK...
(sorry for the tedious check, but some systems have not too clean
 header files, to say the least;  '+' means OK, '-' means not defined
 and '*' has compile problems...)
+B0 +B110 +B115200 +B1200 +B134 +B150 -B153600 +B1800 +B19200 +B200 +B230400 +B2400 +B300 -B307200 +B38400 +B460800 +B4800 +B50 +B57600 +B600 +B75 +B76800 +B9600 +BRKINT -BS0 -BS1 -BSDLY -CBAUD -CBAUDEXT +CBRK +CCTS_OFLOW -CDEL +CDSUSP +CEOF +CEOL -CEOL2 +CEOT +CERASE -CESC +CFLUSH -CIBAUD -CIBAUDEXT +CINTR +CKILL +CLNEXT +CLOCAL -CNSWTCH -CNUL +CQUIT -CR0 -CR1 -CR2 -CR3 -CRDLY +CREAD +CRPRNT +CRTSCTS -CRTSXOFF +CRTS_IFLOW +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTART +CSTOP +CSTOPB +CSUSP -CSWTCH +CWERASE -DEFECHO -DIOC -DIOCGETP -DIOCSETP -DOSMODE +ECHO +ECHOCTL +ECHOE +ECHOK +ECHOKE +ECHONL +ECHOPRT +EXTA +EXTB -FF0 -FF1 -FFDLY -FIORDCHK +FLUSHO +HUPCL +ICANON +ICRNL +IEXTEN +IGNBRK +IGNCR +IGNPAR +IMAXBEL +INLCR +INPCK +ISIG +ISTRIP -IUCLC +IXANY +IXOFF +IXON -KBENABLED -LDCHG -LDCLOSE -LDDMAP -LDEMAP -LDGETT -LDGMAP -LDIOC -LDNMAP -LDOPEN -LDSETT -LDSMAP -LOBLK +NCCS -NL0 -NL1 -NLDLY +NOFLSH +OCRNL -OFDEL -OFILL -OLCUC +ONLCR +ONLRET +ONOCR +OPOST -PAGEOUT +PARENB -PAREXT +PARMRK +PARODD +PENDIN -RCV1EN -RTS_TOG -TAB0 -TAB1 -TAB2 -TAB3 -TABDLY -TCDSET -TCFLSH -TCGETA -TCGETS +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCSADRAIN +TCSAFLUSH +TCSANOW -TCSBRK -TCSETA -TCSETAF -TCSETAW -TCSETCTTY -TCSETS -TCSETSF -TCSETSW -TCXONC -TERM_D40 -TERM_D42 -TERM_H45 -TERM_NONE -TERM_TEC -TERM_TEX -TERM_V10 -TERM_V61 +TIOCCBRK +TIOCCDTR +TIOCCONS +TIOCEXCL +TIOCFLUSH -TIOCGETC +TIOCGETD -TIOCGETP -TIOCGLTC +TIOCGPGRP -TIOCGSID -TIOCGSOFTCAR +TIOCGWINSZ -TIOCHPCL -TIOCKBOF -TIOCKBON -TIOCLBIC -TIOCLBIS -TIOCLGET -TIOCLSET +TIOCMBIC +TIOCMBIS +TIOCMGET +TIOCMSET +TIOCM_CAR +TIOCM_CD +TIOCM_CTS +TIOCM_DSR +TIOCM_DTR +TIOCM_LE +TIOCM_RI +TIOCM_RNG +TIOCM_RTS +TIOCM_SR +TIOCM_ST +TIOCNOTTY +TIOCNXCL +TIOCOUTQ -TIOCREMOTE +TIOCSBRK +TIOCSCTTY +TIOCSDTR -TIOCSETC +TIOCSETD -TIOCSETN -TIOCSETP -TIOCSIGNAL -TIOCSLTC +TIOCSPGRP -TIOCSSID -TIOCSSOFTCAR +TIOCSTART +TIOCSTI +TIOCSTOP +TIOCSWINSZ -TM_ANL -TM_CECHO -TM_CINVIS -TM_LCF -TM_NONE -TM_SET -TM_SNL +TOSTOP -VCEOF -VCEOL +VDISCARD +VDSUSP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VLNEXT +VMIN +VQUIT +VREPRINT +VSTART +VSTOP +VSUSP -VSWTCH -VT0 -VT1 -VTDLY +VTIME +VWERASE -WRAP -XCASE -XCLUDE -XMT1EN -XTABS 
 
>>> Configuration looks good! <<<
 
Writing IO::Tty::Constant.pm...
DEFINE = -DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_TERMIOS_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT
Checking if your kit is complete...
Looks good
Writing Makefile for IO::Tty
===>  Building for p5-IO-Tty-1.07
cp Tty.pm blib/lib/IO/Tty.pm
cp Tty/Constant.pm blib/lib/IO/Tty/Constant.pm
cp Pty.pm blib/lib/IO/Pty.pm
/usr/local/bin/perl5.8.8 /usr/local/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/local/lib/perl5/5.8.8/ExtUtils/typemap  Tty.xs > Tty.xsc && mv Tty.xsc Tty.c
cc -c    -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe    -DVERSION=\"1.07\"  -DXS_VERSION=\"1.07\" -DPIC -fPIC "-I/usr/local/lib/perl5/5.8.8/mach/CORE"  -DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_TERMIOS_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT Tty.c
Running Mkbootstrap for IO::Tty ()
chmod 644 Tty.bs
rm -f blib/arch/auto/IO/Tty/Tty.so
cc  -shared  -L/usr/local/lib Tty.o  -o blib/arch/auto/IO/Tty/Tty.so      -lutil         
chmod 755 blib/arch/auto/IO/Tty/Tty.so
cp Tty.bs blib/arch/auto/IO/Tty/Tty.bs
chmod 644 blib/arch/auto/IO/Tty/Tty.bs
Manifying blib/man3/IO::Tty::Constant.3
Manifying blib/man3/IO::Tty.3
Manifying blib/man3/IO::Pty.3
===>  Installing for p5-IO-Tty-1.07
===>   p5-IO-Tty-1.07 depends on file: /usr/local/bin/perl5.8.8 - found
===>   Generating temporary packing list
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Tty::Constant.3
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Tty.3
Installing /usr/local/lib/perl5/5.8.8/man/man3/IO::Pty.3
Writing /usr/local/lib/perl5/site_perl/5.8.8/mach/auto/IO/Tty/.packlist
===>   Compressing manual pages for p5-IO-Tty-1.07
===>   Registering installation for p5-IO-Tty-1.07
===>  Cleaning for p5-IO-Tty-1.07
```


Now the problem is even more serious. I can't run the script at all. it gives the following error:


```
Cannot create a new IO::Tty from fd 4: Bad file descriptor at /usr/local/lib/perl5/site_perl/5.8.8/V6evalRemote.pm line 637
NG
  -> internal error
```
 
the line above is the following:

```
$Remote = Expect->spawn("$TermCmd");
```
 
It seems the script can't log into the router. What to do now? Is there any way of undoing this all?


----------



## DutchDaemon (Apr 30, 2009)

swaprava, use code tags for system output. Otherwise your posts are unreadable.


----------



## swaprava (May 1, 2009)

DutchDaemon said:
			
		

> swaprava, use code tags for system output. Otherwise your posts are unreadable.



Sorry, I didn't notice this. Will format properly from next post onwards.


----------



## SirDice (May 1, 2009)

Where do these r* commands come from anyway?


----------



## swaprava (May 9, 2009)

Well, finally I figured out that my IO port was outdated, version 1.07, I upgraded it to 1.08 using the following:


```
portupgrade -fRv p5-IO-Tty
```

and it worked after that.


----------

