how to build the zlib shared library?

how to build the zlib shared library?

Post by vervoo » Fri, 19 Apr 2002 18:48:41



Hi,

Could someone tell me how to build zlib as a shared library on AIX. I've
tried configure -s but this is what I get:

$ ./configure -s
Checking for shared library support...
No shared library suppport; try without defining CC and CFLAGS
Building static library libz.a version 1.1.4 with cc -G.
Checking for unistd.h... Yes.
Checking for errno.h...  Yes.

Thanks for any help.

JS.

 
 
 

how to build the zlib shared library?

Post by Marc Stephens » Fri, 19 Apr 2002 21:27:38




>Hi,

>Could someone tell me how to build zlib as a shared library on AIX. I've
>tried configure -s but this is what I get:

>$ ./configure -s
>Checking for shared library support...
>No shared library suppport; try without defining CC and CFLAGS
>Building static library libz.a version 1.1.4 with cc -G.
>Checking for unistd.h... Yes.
>Checking for errno.h...  Yes.

>Thanks for any help.

>JS.

We created this patch for it, then used ./configure --shared and make libz.a and make.
We also archived libz.so.1 into a libz.a.

Index: zlib-1.1.3/configure
diff -c zlib-1.1.3/configure:1.1.1.1 zlib-1.1.3/configure:1.6
*** zlib-1.1.3/configure:1.1.1.1        Mon Jun 12 16:00:21 2000
--- zlib-1.1.3/configure        Wed Mar  7 21:27:50 2001
***************
*** 69,75 ****

  if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
    CC="$cc"
!   SFLAGS=${CFLAGS-"-fPIC -O3"}
    CFLAGS="$cflags"
    case `(uname -s || echo unknown) 2>/dev/null` in
    Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
--- 69,80 ----

  if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
    CC="$cc"
!   # All code is PIC on AIX.
!   case `(uname -s || echo unknown) 2>/dev/null` in
!   AIX*) SFLAGS=${CFLAGS-"-O3"}
!         SHAREDLIB='libz.so';;
!   *)    SFLAGS=${CFLAGS-"-fPIC -O3"};;
!   esac
    CFLAGS="$cflags"
    case `(uname -s || echo unknown) 2>/dev/null` in
    Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
***************
*** 79,84 ****
--- 84,99 ----
    # find system name and corresponding cc options
    CC=${CC-cc}
    case `(uname -sr || echo unknown) 2>/dev/null` in
+   AIX*)      SFLAGS=${CFLAGS-"-O3"}
+              case `(uname -m) 2>/dev/null` in
+            ia64) if test "$gcc" -eq 1; then
+                     LDSHARED=${LDSHARED-"$CC -shared  -Wl,-h,libz.so.1"}
+                  else
+                     LDSHARED=${LDSHARED-"$CC -G -Wl,-h,libz.so.1"}
+                  fi;;
+            *)LDSHARED=${LDSHARED-"$CC -G"};;
+            esac
+            ;;
    HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
             CFLAGS=${CFLAGS-"-O"}
  #          LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
***************
*** 126,133 ****
  if test $shared -eq 1; then
    echo Checking for shared library support...
    # we must test in two steps (cc then ld), required at least on SunOS 4.x
!   if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
!      test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
      CFLAGS="$SFLAGS"
      LIBS="$SHAREDLIB.$VER"
      echo Building shared library $SHAREDLIB.$VER with $CC.
--- 137,144 ----
  if test $shared -eq 1; then
    echo Checking for shared library support...
    # we must test in two steps (cc then ld), required at least on SunOS 4.x
!   $CC -c $SFLAGS $test.c 2>&1 && $LDSHARED -o $test$shared_ext $test.o 2>&1
!   if test $?; then
      CFLAGS="$SFLAGS"
      LIBS="$SHAREDLIB.$VER"
      echo Building shared library $SHAREDLIB.$VER with $CC.
--
Marc Stephenson                        IBM Server Group - Austin,TX


 
 
 

how to build the zlib shared library?

Post by vervoo » Fri, 19 Apr 2002 23:24:10


Marc,

Not sure if I've done this correctly. I changed the occurrences of
zlib-1.1.3 to 1.1.4 and applied your patch as follows:

$ patch -p1 < zlib.diff
Processing...  Looks like a new-style context diff...
The text leading up to this was:
--------------------------
|Index: zlib-1.1.4/configure
|diff -c zlib-1.1.4/configure:1.1.1.1 zlib-1.1.4/configure:1.6
|*** zlib-1.1.4/configure:1.1.1.1       Mon Jun 12 16:00:21 2000
|--- zlib-1.1.4/configure       Wed Mar  7 21:27:50 2001
--------------------------
Patching file configure using Plan A...
Hunk #1 succeeded at 69.
Hunk #2 succeeded at 84.
Hunk #3 succeeded at 137.
Processing...  Ignoring the trailing text.
done
$

Then ran configure -s and make:

        cc -G -O3 -DHAVE_UNISTD_H -DUSE_MMAP -c inffast.c
     1500-036: (I) Optimization level 3 has the potential to alter the
semantics of a program.  Please refer to documentation on -O3 and the
STRICT option for more information.
         cc -G -G -o libz.so.1.1.4 adler32.o compress.o crc32.o gzio.o
uncompr.o deflate.o trees.o  zutil.o inflate.o infblock.o inftrees.o
infcodes.o infutil.o inffast.o
         rm -f libz.so libz.so.1
         ln -s libz.so.1.1.4 libz.so
         ln -s libz.so.1.1.4 libz.so.1
         cc -G -O3 -DHAVE_UNISTD_H -DUSE_MMAP -o example example.o -L. -lz
ld: 0706-006 Cannot find or open library file: -l z
         ld:open(): A file or directory in the path name does not exist.
make: 1254-004 The error code from the last command is 255.

But this ended with the above error, although it did create the .so files:

libz.so
libz.so.1
libz.so.1.1.4




>>Hi,

>>Could someone tell me how to build zlib as a shared library on AIX. I've
>>tried configure -s but this is what I get:

>>$ ./configure -s
>>Checking for shared library support...
>>No shared library suppport; try without defining CC and CFLAGS
>>Building static library libz.a version 1.1.4 with cc -G.
>>Checking for unistd.h... Yes.
>>Checking for errno.h...  Yes.

>>Thanks for any help.

>>JS.

> We created this patch for it, then used ./configure --shared and make libz.a and make.
> We also archived libz.so.1 into a libz.a.

> Index: zlib-1.1.3/configure
> diff -c zlib-1.1.3/configure:1.1.1.1 zlib-1.1.3/configure:1.6
> *** zlib-1.1.3/configure:1.1.1.1   Mon Jun 12 16:00:21 2000
> --- zlib-1.1.3/configure   Wed Mar  7 21:27:50 2001
> ***************
> *** 69,75 ****

>   if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
>     CC="$cc"
> !   SFLAGS=${CFLAGS-"-fPIC -O3"}
>     CFLAGS="$cflags"
>     case `(uname -s || echo unknown) 2>/dev/null` in
>     Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
> --- 69,80 ----

>   if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
>     CC="$cc"
> !   # All code is PIC on AIX.
> !   case `(uname -s || echo unknown) 2>/dev/null` in
> !   AIX*) SFLAGS=${CFLAGS-"-O3"}
> !         SHAREDLIB='libz.so';;
> !   *)    SFLAGS=${CFLAGS-"-fPIC -O3"};;
> !   esac
>     CFLAGS="$cflags"
>     case `(uname -s || echo unknown) 2>/dev/null` in
>     Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
> ***************
> *** 79,84 ****
> --- 84,99 ----
>     # find system name and corresponding cc options
>     CC=${CC-cc}
>     case `(uname -sr || echo unknown) 2>/dev/null` in
> +   AIX*)      SFLAGS=${CFLAGS-"-O3"}
> +              case `(uname -m) 2>/dev/null` in
> +            ia64) if test "$gcc" -eq 1; then
> +                     LDSHARED=${LDSHARED-"$CC -shared  -Wl,-h,libz.so.1"}
> +                  else
> +                     LDSHARED=${LDSHARED-"$CC -G -Wl,-h,libz.so.1"}
> +                  fi;;
> +       *)LDSHARED=${LDSHARED-"$CC -G"};;
> +       esac
> +       ;;
>     HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
>         CFLAGS=${CFLAGS-"-O"}
>   #             LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
> ***************
> *** 126,133 ****
>   if test $shared -eq 1; then
>     echo Checking for shared library support...
>     # we must test in two steps (cc then ld), required at least on SunOS 4.x
> !   if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
> !      test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
>       CFLAGS="$SFLAGS"
>       LIBS="$SHAREDLIB.$VER"
>       echo Building shared library $SHAREDLIB.$VER with $CC.
> --- 137,144 ----
>   if test $shared -eq 1; then
>     echo Checking for shared library support...
>     # we must test in two steps (cc then ld), required at least on SunOS 4.x
> !   $CC -c $SFLAGS $test.c 2>&1 && $LDSHARED -o $test$shared_ext $test.o 2>&1
> !   if test $?; then
>       CFLAGS="$SFLAGS"
>       LIBS="$SHAREDLIB.$VER"
>       echo Building shared library $SHAREDLIB.$VER with $CC.

 
 
 

how to build the zlib shared library?

Post by Marc Stephens » Sat, 20 Apr 2002 04:52:51


The Makefile generates a .so instead of a .a, so the -lz in the build of the
example will fail.  If you run ar -qv libz.a libz.so.1, then you'll be in business.



>Marc,

>Not sure if I've done this correctly. I changed the occurrences of
>zlib-1.1.3 to 1.1.4 and applied your patch as follows:

>$ patch -p1 < zlib.diff
>Processing...  Looks like a new-style context diff...
>The text leading up to this was:
>--------------------------
>|Index: zlib-1.1.4/configure
>|diff -c zlib-1.1.4/configure:1.1.1.1 zlib-1.1.4/configure:1.6
>|*** zlib-1.1.4/configure:1.1.1.1       Mon Jun 12 16:00:21 2000
>|--- zlib-1.1.4/configure       Wed Mar  7 21:27:50 2001
>--------------------------
>Patching file configure using Plan A...
>Hunk #1 succeeded at 69.
>Hunk #2 succeeded at 84.
>Hunk #3 succeeded at 137.
>Processing...  Ignoring the trailing text.
>done
>$

>Then ran configure -s and make:

>    cc -G -O3 -DHAVE_UNISTD_H -DUSE_MMAP -c inffast.c
>     1500-036: (I) Optimization level 3 has the potential to alter the
>semantics of a program.  Please refer to documentation on -O3 and the
>STRICT option for more information.
>         cc -G -G -o libz.so.1.1.4 adler32.o compress.o crc32.o gzio.o
>uncompr.o deflate.o trees.o  zutil.o inflate.o infblock.o inftrees.o
>infcodes.o infutil.o inffast.o
>         rm -f libz.so libz.so.1
>         ln -s libz.so.1.1.4 libz.so
>         ln -s libz.so.1.1.4 libz.so.1
>         cc -G -O3 -DHAVE_UNISTD_H -DUSE_MMAP -o example example.o -L. -lz
>ld: 0706-006 Cannot find or open library file: -l z
>         ld:open(): A file or directory in the path name does not exist.
>make: 1254-004 The error code from the last command is 255.

>But this ended with the above error, although it did create the .so files:

>libz.so
>libz.so.1
>libz.so.1.1.4




>>>Hi,

>>>Could someone tell me how to build zlib as a shared library on AIX. I've
>>>tried configure -s but this is what I get:

>>>$ ./configure -s
>>>Checking for shared library support...
>>>No shared library suppport; try without defining CC and CFLAGS
>>>Building static library libz.a version 1.1.4 with cc -G.
>>>Checking for unistd.h... Yes.
>>>Checking for errno.h...  Yes.

>>>Thanks for any help.

>>>JS.

>> We created this patch for it, then used ./configure --shared and make libz.a and make.
>> We also archived libz.so.1 into a libz.a.

>> Index: zlib-1.1.3/configure
>> diff -c zlib-1.1.3/configure:1.1.1.1 zlib-1.1.3/configure:1.6
>> *** zlib-1.1.3/configure:1.1.1.1       Mon Jun 12 16:00:21 2000
>> --- zlib-1.1.3/configure       Wed Mar  7 21:27:50 2001
>> ***************
>> *** 69,75 ****

>>   if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
>>     CC="$cc"
>> !   SFLAGS=${CFLAGS-"-fPIC -O3"}
>>     CFLAGS="$cflags"
>>     case `(uname -s || echo unknown) 2>/dev/null` in
>>     Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
>> --- 69,80 ----

>>   if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
>>     CC="$cc"
>> !   # All code is PIC on AIX.
>> !   case `(uname -s || echo unknown) 2>/dev/null` in
>> !   AIX*) SFLAGS=${CFLAGS-"-O3"}
>> !         SHAREDLIB='libz.so';;
>> !   *)    SFLAGS=${CFLAGS-"-fPIC -O3"};;
>> !   esac
>>     CFLAGS="$cflags"
>>     case `(uname -s || echo unknown) 2>/dev/null` in
>>     Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
>> ***************
>> *** 79,84 ****
>> --- 84,99 ----
>>     # find system name and corresponding cc options
>>     CC=${CC-cc}
>>     case `(uname -sr || echo unknown) 2>/dev/null` in
>> +   AIX*)      SFLAGS=${CFLAGS-"-O3"}
>> +              case `(uname -m) 2>/dev/null` in
>> +            ia64) if test "$gcc" -eq 1; then
>> +                     LDSHARED=${LDSHARED-"$CC -shared  -Wl,-h,libz.so.1"}
>> +                  else
>> +                     LDSHARED=${LDSHARED-"$CC -G -Wl,-h,libz.so.1"}
>> +                  fi;;
>> +           *)LDSHARED=${LDSHARED-"$CC -G"};;
>> +           esac
>> +           ;;
>>     HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
>>             CFLAGS=${CFLAGS-"-O"}
>>   #         LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
>> ***************
>> *** 126,133 ****
>>   if test $shared -eq 1; then
>>     echo Checking for shared library support...
>>     # we must test in two steps (cc then ld), required at least on SunOS 4.x
>> !   if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
>> !      test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
>>       CFLAGS="$SFLAGS"
>>       LIBS="$SHAREDLIB.$VER"
>>       echo Building shared library $SHAREDLIB.$VER with $CC.
>> --- 137,144 ----
>>   if test $shared -eq 1; then
>>     echo Checking for shared library support...
>>     # we must test in two steps (cc then ld), required at least on SunOS 4.x
>> !   $CC -c $SFLAGS $test.c 2>&1 && $LDSHARED -o $test$shared_ext $test.o 2>&1
>> !   if test $?; then
>>       CFLAGS="$SFLAGS"
>>       LIBS="$SHAREDLIB.$VER"
>>       echo Building shared library $SHAREDLIB.$VER with $CC.

--
Marc Stephenson                        IBM Server Group - Austin,TX

 
 
 

1. Help with building shared libraries with dependencies on other shared libraries

Hi all,

I'm having problems running my application in Linux (RedHat 7.1) that loads
up ten shared libraries, all but one have dependencies with the other shared
libraries. The application is written in Java, so in the code I load up the
libraries using

System.loadLibrary("lib1");

The libraries are written in C++ and I'm using VIDE (integrated development
environment) to create my makefile. The complier is g++ and for linking
flags I have: -fPIC -shared.

When I try to run my application on Linux, it loads up the first shared
library lib1 correctly but when it tries to load the second one lib2 it
complains about unresolved symbols, the ones that were defined in lib1. When
I compiled all the code and made it lib1, the application worked but for
this project it is required that I have multiple shared libraries. So is
there a way to build these libraries that are dependent on each other so
that I won't have the unresolved symbols problem or is there a way in Java
to load up all the libraries simultaneously? Any help is appreciated.
Thanks,

Johnny

2. Required inputs from an executible.

3. compiling zlib-1.0.8: No shared library suppport?

4. test

5. Building shared library which includes static libraries

6. Installation problems with Adaptec 1542 resolved

7. Building shared libraries that contain static libraries.

8. On a roll! Why can I not rpm --rebuild enlightenment?

9. Using libtool to build shared libraries that depend on static libraries

10. Will strip(debug shared library) == nodebug shared library ?

11. Question: Inclusion of shared libraries during linking of shared libraries

12. Shared library loading shared library.

13. Need a Shared Library Guru: beyond simple shared library question