Subject: Re: [libssh2] 2 bugs in libssh2

Re: [libssh2] 2 bugs in libssh2

From: Daniel Johnson <daniel_at_daniel-johnson.org>
Date: Tue, 27 Mar 2007 11:23:29 -0400

On Mar 27, 2007, at 9:17 AM, Simon Josefsson wrote:

> Daniel Johnson <daniel_at_daniel-johnson.org> writes:
>
>> The other bug is in tests/Makefile.in. The "AM_LDFLAGS = -no-install"
>> should be omitted, since it tells libtool to not use a wrapper
>> script. This causes simple to try to link to an already installed
>> libssh2, not the one just built. So it either uses the wrong libssh2
>> or fails to build if libssh2 isn't installed at all.
>
> That is not what -no-install should be doing, here is the doc for it:
>
> `-no-install'
> Link an executable OUTPUT-FILE that can't be installed and
> therefore doesn't need a wrapper script. Useful if the
> program is
> only used in the build tree, e.g., for testing or generating
> other
> files.
>
> I don't have libssh2 installed on this machine, and building and
> linking 'simple' works:
>
> jas_at_mocca:~/src/libssh2/tests$ make clean
> rm -f simple simple
> rm -rf .libs _libs
> rm -f *.o
> rm -f *.lo
> jas_at_mocca:~/src/libssh2/tests$ make check
> make simple
> make[1]: Entering directory `/home/jas/src/libssh2/tests'
> gcc -DHAVE_CONFIG_H -I. -I../src -I../include -g -O2 -I/usr/
> local/include -I/usr/include -MT simple.o -MD -MP -MF .deps/
> simple.Tpo -c -o simple.o simple.c
> mv -f .deps/simple.Tpo .deps/simple.Po
> /bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -I/usr/local/
> include -I/usr/include -no-install -L/usr/local/lib -lgcrypt -lgpg-
> error -L/usr/lib -lz -o simple simple.o ../src/libssh2.la
> mkdir .libs
> gcc -g -O2 -I/usr/local/include -I/usr/include -o simple simple.o -
> L/usr/local/lib /usr/local/lib/libgcrypt.so /usr/local/lib/libgpg-
> error.so -L/usr/lib -lz ../src/.libs/libssh2.so -Wl,--rpath -Wl,/
> usr/local/lib -Wl,--rpath -Wl,/home/jas/src/libssh2/src/.libs -Wl,--
> rpath -Wl,/usr/local/lib
> make[1]: Leaving directory `/home/jas/src/libssh2/tests'
> make check-TESTS
> make[1]: Entering directory `/home/jas/src/libssh2/tests'
> PASS: simple
> ==================
> All 1 tests passed
> ==================
> make[1]: Leaving directory `/home/jas/src/libssh2/tests'
> jas_at_mocca:~/src/libssh2/tests$
>
> It uses ../src/libssh2.la which expands to ../src/.libs/libssh2.so.
> That seems correct to me.
>
> Could you please describe the symptoms of your problem in more detail?
>
> Which libtool version are you using? I'm using 1.5.22.

This is what I get with a fresh cvs checkout and no libssh2 already
installed:

$ make check
Making check in src
make[1]: Nothing to be done for `check'.
Making check in example
Making check in simple
make[2]: Nothing to be done for `check'.
make[2]: Nothing to be done for `check-am'.
Making check in tests
make simple
gcc -DHAVE_CONFIG_H -I. -I../src -I../include -DLIBSSH2_DARWIN -I/
usr/include -I/usr/include -MT simple.o -MD -MP -MF .deps/simple.Tpo -
c -o simple.o simple.c
mv -f .deps/simple.Tpo .deps/simple.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -DLIBSSH2_DARWIN -I/
usr/include -I/usr/include -no-install -L/usr/lib -lcrypto -L/usr/lib
-lz -o simple simple.o ../src/libssh2.la
mkdir .libs
gcc -DLIBSSH2_DARWIN -I/usr/include -I/usr/include -o simple
simple.o -L/usr/lib ../src/.libs/libssh2.dylib -lcrypto -lz
make check-TESTS
dyld: Library not loaded: /usr/local/lib/libssh2.1.dylib
   Referenced from: /Users/daniel/Desktop/libssh2/tests/./simple
   Reason: image not found
FAIL: simple
====================================================
1 of 1 tests failed
Please report to libssh2-devel_at_lists.sourceforge.net
====================================================
make[2]: *** [check-TESTS] Error 1
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1

"simple" is linked to /usr/local/lib/libssh2.1.dylib, but since that
library isn't present it fails to run. In this case, tests/simple is
a binary. If I remove -no-install I get this:

$ make check
Making check in src
make[1]: Nothing to be done for `check'.
Making check in example
Making check in simple
make[2]: Nothing to be done for `check'.
make[2]: Nothing to be done for `check-am'.
Making check in tests
make simple
gcc -DHAVE_CONFIG_H -I. -I../src -I../include -DLIBSSH2_DARWIN -I/
usr/include -I/usr/include -MT simple.o -MD -MP -MF .deps/simple.Tpo -
c -o simple.o simple.c
mv -f .deps/simple.Tpo .deps/simple.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -DLIBSSH2_DARWIN -I/
usr/include -I/usr/include -L/usr/lib -lcrypto -L/usr/lib -lz -o
simple simple.o ../src/libssh2.la
mkdir .libs
gcc -DLIBSSH2_DARWIN -I/usr/include -I/usr/include -o .libs/simple
simple.o -L/usr/lib ../src/.libs/libssh2.dylib -lcrypto -lz
creating simple
make check-TESTS
PASS: simple
==================
All 1 tests passed
==================
Making check in docs
make[1]: Nothing to be done for `check'.
make[1]: Nothing to be done for `check-am'.

Now tests/simple is a shell script with the actual binary in
tests/.libs/simple. This is the script:

#! /bin/sh

# simple - temporary wrapper script for .libs/simple
# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365
2005/12/18 22:14:06)
#
# The simple program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.

# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed='/sw/bin/sed -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'

# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

relink_command=""

# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
   # install mode needs the following variable:
   notinst_deplibs=' ../src/libssh2.la'
else
   # When we are sourced in execute mode, $file and $echo are already
set.
   if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
     echo="echo"
     file="$0"
     # Make sure echo works.
     if test "X$1" = X--no-reexec; then
       # Discard the --no-reexec flag, and continue.
       shift
     elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
       # Yippee, $echo works!
       :
     else
       # Restart under the correct shell, and then maybe $echo will
work.
       exec /bin/sh "$0" --no-reexec ${1+"$@"}
     fi
   fi

   # Find the directory that this script lives in.
   thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
   test "x$thisdir" = "x$file" && thisdir=.

   # Follow symbolic links until we get to the real thisdir.
   file=`ls -ld "$file" | /sw/bin/sed -n 's/.*-> //p'`
   while test -n "$file"; do
     destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`

     # If there was a directory component, then change thisdir.
     if test "x$destdir" != "x$file"; then
       case "$destdir" in
       [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
       *) thisdir="$thisdir/$destdir" ;;
       esac
     fi

     file=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
     file=`ls -ld "$thisdir/$file" | /sw/bin/sed -n 's/.*-> //p'`
   done

   # Try to get the absolute directory name.
   absdir=`cd "$thisdir" && pwd`
   test -n "$absdir" && thisdir="$absdir"

   program='simple'
   progdir="$thisdir/.libs"

   if test -f "$progdir/$program"; then
     # Add our own library path to DYLD_LIBRARY_PATH
     DYLD_LIBRARY_PATH="/Users/daniel/Desktop/libssh2/src/.libs:
$DYLD_LIBRARY_PATH"

     # Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH
     # The second colon is a workaround for a bug in BeOS R4 sed
     DYLD_LIBRARY_PATH=`$echo "X$DYLD_LIBRARY_PATH" | $Xsed -e 's/::*
$//'`

     export DYLD_LIBRARY_PATH

     if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
       # Run the actual program with our arguments.

       exec "$progdir/$program" ${1+"$@"}

       $echo "$0: cannot exec $program ${1+"$@"}"
       exit 1
     fi
   else
     # The program doesn't exist.
     $echo "$0: error: \`$progdir/$program' does not exist" 1>&2
     $echo "This script is just a wrapper for $program." 1>&2
     echo "See the libtool documentation for more information." 1>&2
     exit 1
   fi
fi

The script sets up DYLD_LIBRARY_PATH so that Darwin's linker can find
things. This is definitely a Darwinism needed because of Darwin's
wacky linker. This is with libtool 1.5.22.

Please let me know if I can provide any more information.

Daniel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-03-27