Hey, sorry, but spoke too soon, I wasn’t paying attention and shared libraries
on macOS have a suffix of .dylib. Also found the liblz.1.14.[so|dylib] was
being removed on install after it was installed and the libel.1.14.[so|dylib]
was linking back to itself. I’ve made some changes to the Makefile.in and
configure files, Here are the cumulative diffs.
* Put the version and suffix in the proper order
* Added a sosuffix to handle macOS with dylib, and everything else defaults
to .so
* Did a check with uname -s to see if this is running on macOS Darwin
kernel.
(base) [unixwzrd@xanax: lzlib-1.14]$ diff Makefile.in Makefile.dist.in
28,29c28,29
< lib$(libname).$(soversion).$(sosuffix) : lzlib.o
< $(CC) $(CFLAGS) $(LDFLAGS) -fpic -fPIC -shared -o $@ $<
---
> lib$(libname).so.$(pkgversion) : lzlib_sh.o
> $(CC) $(CFLAGS) $(LDFLAGS) -fpic -fPIC -shared
> -Wl,--soname=lib$(libname).so.$(soversion) -o $@ $<
34,35c34,35
< $(progname)_shared : $(objs) lib$(libname).$(soversion).$(sosuffix)
< $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs)
lib$(libname).$(soversion).$(sosuffix)
---
> $(progname)_shared : $(objs) lib$(libname).so.$(pkgversion)
> $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs) lib$(libname).so.$(pkgversion)
48a49,51
> lzlib_sh.o : lzlib.c
> $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -fPIC -c -o $@ $<
>
108,109c111,112
< $(INSTALL_PROGRAM) ./lib$(libname).$(soversion).$(sosuffix)
"$(DESTDIR)$(libdir)/lib$(libname).$(soversion).$(sosuffix)" ; \
< if [ -e "$(DESTDIR)$(libdir)/lib$(libname).$(sosuffix).$(soversion)" ] ;
then \
---
> $(INSTALL_PROGRAM) ./lib$(libname).so.$(pkgversion)
> "$(DESTDIR)$(libdir)/lib$(libname).so.$(pkgversion)" ; \
> if [ -e "$(DESTDIR)$(libdir)/lib$(libname).so.$(soversion)" ] ; then \
113,114c116,119
< rm -f "$(DESTDIR)$(libdir)/lib$(libname).$(sosuffix)" ; \
< cd "$(DESTDIR)$(libdir)" && ln -s lib$(libname).$(soversion).$(sosuffix)
lib$(libname).$(sosuffix) ; \
---
> rm -f "$(DESTDIR)$(libdir)/lib$(libname).so" ; \
> rm -f "$(DESTDIR)$(libdir)/lib$(libname).so.$(soversion)" ; \
> cd "$(DESTDIR)$(libdir)" && ln -s lib$(libname).so.$(pkgversion)
> lib$(libname).so ; \
> cd "$(DESTDIR)$(libdir)" && ln -s lib$(libname).so.$(pkgversion)
> lib$(libname).so.$(soversion) ; \
153,154c158,160
< -rm -f "$(DESTDIR)$(libdir)/lib$(libname).$(sosuffix)"
< -rm -f "$(DESTDIR)$(libdir)/lib$(libname).$(soversion).$(sosuffix)"
---
> -rm -f "$(DESTDIR)$(libdir)/lib$(libname).so"
> -rm -f "$(DESTDIR)$(libdir)/lib$(libname).so.$(soversion)"
> -rm -f "$(DESTDIR)$(libdir)/lib$(libname).so.$(pkgversion)"
195c201
< -rm -f $(progname)_shared lzlib_sh.o lib$(libname).$(sosuffix)*
---
> -rm -f $(progname)_shared lzlib_sh.o lib$(libname).so*
(base) [unixwzrd@xanax: lzlib-1.14]$ diff configure configure.dist
10,12c10
< # soversion=1.14
< soversion=${pkgversion}
< sosuffix=os
---
> soversion=1
124,126d121
< if [ $(uname -s) = "Darwin" ] ; then
< sosuffix=dylib
< fi
205d199
< echo "sosuffix = ${sosuffix}"
228d221
< sosuffix = ${sosuffix}
Hope this helps, let me know if it works out alright, seems to work on macOS
now, should also work on any other OS, which uses .so but I haven’t had a
chance to try it out.
Cheers,
Mike
---
Michael Sullivan
Distributed Thinking Systems LLC<https://unixwzrd.ai/>
[email protected]
LinkedIn: https://www.linkedin.com/in/unixwzrd/
GitHub: https://github.com/unixwzrd
Phone: +1-662-202-7716
On Oct 18, 2024, at 13:52, M S <[email protected]> wrote:
Hi,
Thanks for the reply. I should have included the output of the make without the
change, it is unable to build the unmodified distribution, as you can see here:
Actually I found another couple of issues when going back and getting the
output, which I missed, but it doesn’t seem to affect the install.
(base) [unixwzrd@xanax: lzlib-1.14]$ make -v
GNU Make 4.4.1
Built for aarch64-apple-darwin24.0.0
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(base) [unixwzrd@xanax: lzlib-1.14]$ ./configure --enable-shared
creating config.status
creating Makefile
VPATH = .
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
includedir = $(prefix)/include
infodir = $(datarootdir)/info
libdir = $(exec_prefix)/lib
mandir = $(datarootdir)/man
CC = gcc
AR = ar
CPPFLAGS =
CFLAGS = -Wall -W -O2
LDFLAGS =
ARFLAGS = -rcs
MAKEINFO = makeinfo
OK. Now you can run make.
(base) [unixwzrd@xanax: lzlib-1.14]$ make
gcc -Wall -W -O2 -c -o carg_parser.o carg_parser.c
gcc -Wall -W -O2 -DPROGVERSION=\"1.14\" -c -o minilzip.o minilzip.c
gcc -Wall -W -O2 -c -o lzlib.o lzlib.c
ar -rcs liblz.a lzlib.o
gcc -Wall -W -O2 -o minilzip carg_parser.o minilzip.o liblz.a
gcc -Wall -W -O2 -fpic -fPIC -c -o lzlib_sh.o lzlib.c
gcc -Wall -W -O2 -fpic -fPIC -shared -Wl,--soname=liblz.so.1 -o liblz.so.1.14
lzlib_sh.o
ld: unknown options: --soname=liblz.so.1
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: liblz.so.1.14] Error 1
This fails because the linker is looking for the library, “—soname=liblz.so.1”
which does not exist. Also this linker argument is to link with that library.
Here it is with the —soname removed, but the soversion in the Makefile is set
to 1, and that can’t be found either. The linker cannot find "libel.so.1"
(base) [unixwzrd@xanax: lzlib-1.14]$ make
gcc -Wall -W -O2 -c -o carg_parser.o carg_parser.c
gcc -Wall -W -O2 -DPROGVERSION=\"1.14\" -c -o minilzip.o minilzip.c
gcc -Wall -W -O2 -c -o lzlib.o lzlib.c
ar -rcs liblz.a lzlib.o
gcc -Wall -W -O2 -o minilzip carg_parser.o minilzip.o liblz.a
gcc -Wall -W -O2 -fpic -fPIC -c -o lzlib_sh.o lzlib.c
gcc -Wall -W -O2 -fpic -fPIC -shared -Wl,liblz.so.1 -o liblz.so.1.14 lzlib_sh.o
ld: file cannot be open()ed, errno=2 path=liblz.so.1 in 'liblz.so.1'
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: liblz.so.1.14] Error 1
Here is the output with my patch, the linker doesn’t need a stared object to
link with to create the shared object. I also found a few other things which
were inconsistent when looking deeper t reproducing the issue. Seems there was
a lot of issues and confusion over pkgversion and soversion, also the
dependency Here’s the clean compile:
(base) [unixwzrd@xanax: lzlib-1.14]$ make -v
GNU Make 4.4.1
Built for aarch64-apple-darwin24.0.0
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(base) [unixwzrd@xanax: lzlib-1.14]$ ./configure --enable-shared
creating config.status
creating Makefile
VPATH = .
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
includedir = $(prefix)/include
infodir = $(datarootdir)/info
libdir = $(exec_prefix)/lib
mandir = $(datarootdir)/man
CC = gcc
AR = ar
CPPFLAGS =
CFLAGS = -Wall -W -O2
LDFLAGS =
ARFLAGS = -rcs
MAKEINFO = makeinfo
OK. Now you can run make.
(base) [unixwzrd@xanax: lzlib-1.14]$ make
gcc -Wall -W -O2 -c -o carg_parser.o carg_parser.c
gcc -Wall -W -O2 -DPROGVERSION=\"1.14\" -c -o minilzip.o minilzip.c
gcc -Wall -W -O2 -c -o lzlib.o lzlib.c
ar -rcs liblz.a lzlib.o
gcc -Wall -W -O2 -o minilzip carg_parser.o minilzip.o liblz.a
gcc -Wall -W -O2 -fpic -fPIC -shared -o liblz.so.1.14 lzlib.o
gcc -Wall -W -O2 -o minilzip_shared carg_parser.o minilzip.o liblz.so.1.14
(base) [unixwzrd@xanax: lzlib-1.14]$ diff Makefile.in Makefile.dist.in
28,29c28,29
< lib$(libname).so.$(soversion) : lzlib.o
< $(CC) $(CFLAGS) $(LDFLAGS) -fpic -fPIC -shared -o $@ $<
---
> lib$(libname).so.$(pkgversion) : lzlib_sh.o
> $(CC) $(CFLAGS) $(LDFLAGS) -fpic -fPIC -shared
> -Wl,--soname=lib$(libname).so.$(soversion) -o $@ $<
34,35c34,35
< $(progname)_shared : $(objs) lib$(libname).so.$(soversion)
< $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs) lib$(libname).so.$(soversion)
---
> $(progname)_shared : $(objs) lib$(libname).so.$(pkgversion)
> $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs) lib$(libname).so.$(pkgversion)
47a48,50
>
> lzlib_sh.o : lzlib.c
> $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -fPIC -c -o $@ $<
(base) [unixwzrd@xanax: lzlib-1.14]$ diff configure configure.dist
10,11c10
< # soversion=1.14
< soversion=${pkgversion}
---
> soversion=1
The -Wl, will instruct the linker to link with that library, you really don’t
want the library to try to link with itself, and it won’t work anyway, you will
get duplicate symbol errors IIRC, if someone has LD_LIBRARY_PATH, LD_FLAGS, or
CFLAGS containing a
-L/usr/local/lib
in them. I encountered this issue when trying to compile and link a new version
of libiconv with the new macOS Sequoia libraries, I believe it was which kept
insisting it link with itself in /usr/local/lib. In any event, the lines in
your makefile,
lib$(libname).so.$(soversion) : lzlib.o
$(CC) $(CFLAGS) $(LDFLAGS) -fpic -fPIC -shared -o $@ $<
Will work correctly as shown in the compile above and should work on any other
OS you try it on. $@ expands to the target lib$(libname).so.$(soversion) and $<
will take the dependency, lzlib.o, which is what you want isn’t it?
I also removed the libel_sh.o because it is really unnecessary, once the
libel.o file is built, it just needs the link step to either be made static or
shared. This should also work on any flavor Linux/Unix system as well.
The mini_lzip also gets built too.
Cheers,
Mike
---
Michael Sullivan
Distributed Thinking Systems LLC<https://unixwzrd.ai/>
[email protected]
LinkedIn: https://www.linkedin.com/in/unixwzrd/
GitHub: https://github.com/unixwzrd
Phone: +1-662-202-7716
On Oct 18, 2024, at 11:30, p.z.l <[email protected]> wrote:
. After looking at it I think that lzlib does not need the --soname mechanism;
it
can simply create the shared library as liblz.so.1 instead of liblz.so.1.14.
While I don't have strong opinion on --soname, calling liblz.so.1 instead of
liblz.so.1.15 is somewhat surprising and not well understood. Considering that
virtually all libraries exactly that naming scheme, or notation, ( like in
example: paste.ee/p/xXXxX ).
It (the old scheme) is also useful information in case of testing
different/multiple versions of library.