This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: shared libraries does not work


> can anybody tell me what is wrong?

This should work. I've attached a shar file which, when run, compiles
and runs a program. It works on i486-pc-linux-gnu with egcs-2.93.08.
If you don't get this to run, please report back, or make a more
detailed report on your sample code.

Thanks,
Martin

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1999-02-26 18:17 CET by <martin@mira>.
# Source directory was `/home/martin/tmp/s'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#     13 -rw-rw-r-- a.c
#     13 -rw-rw-r-- b.c
#    142 -rwxrwxr-x makeit
#
# After unpacking everything, makeit will be executed.
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh00784; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= a.c ==============
if test -f 'a.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'a.c' '(file already exists)'
else
  $echo 'x -' extracting 'a.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'a.c' &&
void foo(){}
SHAR_EOF
  $shar_touch -am 0226180899 'a.c' &&
  chmod 0664 'a.c' ||
  $echo 'restore of' 'a.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'a.c:' 'MD5 check failed'
5f98e4807e4f8781c26a82faf819f8a7  a.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'a.c'`"
    test 13 -eq "$shar_count" ||
    $echo 'a.c:' 'original size' '13,' 'current size' "$shar_count!"
  fi
fi
# ============= b.c ==============
if test -f 'b.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'b.c' '(file already exists)'
else
  $echo 'x -' extracting 'b.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'b.c' &&
int main(){}
SHAR_EOF
  $shar_touch -am 0226180899 'b.c' &&
  chmod 0664 'b.c' ||
  $echo 'restore of' 'b.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'b.c:' 'MD5 check failed'
fb18388bff2e2761c8c56dbbbccd182a  b.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'b.c'`"
    test 13 -eq "$shar_count" ||
    $echo 'b.c:' 'original size' '13,' 'current size' "$shar_count!"
  fi
fi
# ============= makeit ==============
if test -f 'makeit' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'makeit' '(file already exists)'
else
  $echo 'x -' extracting 'makeit' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'makeit' &&
#! /bin/sh
set -x
gcc -fPIC -c a.c
gcc -fPIC -shared -o libfoo.so a.o
LD_LIBRARY_PATH=`pwd`
export LD_LIBRARY_PATH
gcc -o b b.c -L. -lfoo
X./b
SHAR_EOF
  $shar_touch -am 0226181799 'makeit' &&
  chmod 0775 'makeit' ||
  $echo 'restore of' 'makeit' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'makeit:' 'MD5 check failed'
057bcbd7a1d07819205a8422b9256025  makeit
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'makeit'`"
    test 142 -eq "$shar_count" ||
    $echo 'makeit:' 'original size' '142,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh00784
./makeit
exit 0



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]