[med-svn] [Git][med-team/libsonlib][master] 3 commits: Link the shared library against libquicktree

Andreas Tille (@tille) gitlab at salsa.debian.org
Fri Nov 6 08:19:37 GMT 2026



Andreas Tille pushed to branch master at Debian Med / libsonlib


Commits:
f0e3cbc8 by Andreas Tille at 2026-11-06T09:11:34+01:00
Link the shared library against libquicktree

libquicktree now ships a shared libquicktree.so.2, so link it into
libsonlib.so instead of leaving the TreeREP symbols unresolved.
Consumers linking against libsonlib.so then resolve them at run time
without adding -lquicktree themselves; the static archive still needs it.

Build against libquicktree-dev >= 2.5-7, the first version that provides
the shared library.

Assisted-By: deepseek-v4.1-flash-free

- - - - -
d2111242 by Andreas Tille at 2026-11-06T09:12:13+01:00
Document that only static linking needs -lquicktree

The shared library now carries the QuickTree dependency itself, so the
README should not tell every consumer to add -lquicktree.  Keep the
instructions for static linking against libsonlib.a.

Assisted-By: deepseek-v4.1-flash-free

- - - - -
d7e3ee71 by Andreas Tille at 2026-11-06T09:13:16+01:00
Only link -lquicktree for the static example

The shared libsonlib.so carries the QuickTree dependency itself now, so
the shared example and the CuTest example must not add -lquicktree.  Keep
it for the example linking libsonlib.a, and adjust the README so both
paths stay documented and covered by the autopkgtest.

Assisted-By: deepseek-v4.1-flash-free

- - - - -


6 changed files:

- debian/README.Debian
- debian/changelog
- debian/control
- debian/examples/Makefile
- debian/examples/README
- debian/patches/add_shared_library.patch


Changes:

=====================================
debian/README.Debian
=====================================
@@ -2,16 +2,25 @@ sonLib for Debian
 =================
 
 SonLib is originally shipped with a code copy of quicktree.  To avoid
-duplicated code the Debian package also builds a static library.  If you
-want to use sonLib in your code you need to add
+duplicated code the Debian package links against the separately packaged
+quicktree.
+
+The shared library libsonlib.so already links libquicktree.so.2, so
+programs that link with -lsonlib get the TreeREP symbols
+(neighbour_joining_buildtree and friends) automatically and no extra
+flags are needed.
+
+The static archive libsonlib.a still leaves the QuickTree symbols
+unresolved.  When linking against it you need
 
-    CFLAGS += -I/usr/include/quicktree
     LIBS += -lquicktree
 
-to build successfully.
+and, if your code also includes quicktree headers directly,
+
+    CFLAGS += -I/usr/include/quicktree
 
 The C test suite uses the CuTest framework from libcutest-dev.  The copy
 that upstream keeps in externalTools is not part of the repacked source
 tarball.
 
- -- Andreas Tille <tille at debian.org>  Mon, 02 Nov 2026 17:56:00 +0100
+ -- Andreas Tille <tille at debian.org>  Fri, 06 Nov 2026 12:00:00 +0100


=====================================
debian/changelog
=====================================
@@ -1,3 +1,17 @@
+libsonlib (1.1+git20220915.5cbc158+dfsg1-2) UNRELEASED; urgency=medium
+
+  * Link the shared library against libquicktree so that the TreeREP
+    symbols (neighbour_joining_buildtree and friends) are resolved at run
+    time and consumers no longer need to add -lquicktree when linking
+    against libsonlib.so.  Build against libquicktree-dev >= 2.5-7, which
+    ships libquicktree.so.2.
+  * Document that linking -lquicktree is only needed for the static
+    archive libsonlib.a.
+  * Drop -lquicktree from the example that links the shared library; keep
+    it for the static example so the autopkgtest covers both paths.
+
+ -- Andreas Tille <tille at debian.org>  Fri, 06 Nov 2026 12:00:00 +0100
+
 libsonlib (1.1+git20220915.5cbc158+dfsg1-1) unstable; urgency=medium
 
   * Cutest is now provided as separate package:


=====================================
debian/control
=====================================
@@ -9,7 +9,7 @@ Build-Depends:
  debhelper-compat (= 14),
  libbz2-dev,
  libcutest-dev,
- libquicktree-dev,
+ libquicktree-dev (>= 2.5-7),
  libtokyocabinet-dev,
  zlib1g-dev,
 Vcs-Browser: https://salsa.debian.org/med-team/libsonlib


=====================================
debian/examples/Makefile
=====================================
@@ -4,10 +4,14 @@ MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 CFLAGS ?= -O2 -g -Wall
 CPPFLAGS ?=
 
-# sonLib itself depends on these libraries.  quicktree is required because
-# libsonlib leaves the quicktree symbols unresolved (libquicktree is a
-# static, non-PIC library).
-SONLIB_LIBS = -lquicktree -ltokyocabinet -lz -lbz2 -lpthread -lm -lstdc++
+# Libraries sonLib itself depends on.  libquicktree is not listed here: the
+# shared libsonlib.so already links it, and for the static archive it is
+# added separately below.
+SONLIB_LIBS = -ltokyocabinet -lz -lbz2 -lpthread -lm -lstdc++
+
+# libsonlib.a leaves the quicktree symbols (neighbour_joining_buildtree and
+# friends) unresolved, so static consumers have to link it explicitly.
+STATIC_SONLIB_LIBS = -lquicktree
 
 .PHONY: all check clean
 
@@ -18,7 +22,7 @@ sonlib-example: sonlib-example.c
 
 sonlib-example-static: sonlib-example.c
 	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< \
-		/usr/lib/$(MULTIARCH)/libsonlib.a $(SONLIB_LIBS)
+		/usr/lib/$(MULTIARCH)/libsonlib.a $(STATIC_SONLIB_LIBS) $(SONLIB_LIBS)
 
 sonlib-cutest-example: sonlib-cutest-example.c
 	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< -lsonlib -lcutest $(SONLIB_LIBS)


=====================================
debian/examples/README
=====================================
@@ -15,4 +15,15 @@ Build and run the examples with:
     make check
 
 The Makefile builds sonlib-example against both the shared and the
-static libsonlib.  The package's autopkgtest uses the same Makefile.
+static libsonlib.  Linking against the shared library needs only
+
+    -lsonlib
+
+because libsonlib.so links libquicktree.so.2 itself.  The static archive
+libsonlib.a leaves the quicktree symbols unresolved, so linking against
+it additionally needs
+
+    -lquicktree
+
+The package's autopkgtest uses the same Makefile and therefore checks
+both ways.


=====================================
debian/patches/add_shared_library.patch
=====================================
@@ -1,16 +1,17 @@
 Description: Build a shared library libsonlib.so.1.1.0 in addition to the static one
  Upstream sonLib only builds the static archive sonLib.a.  Add a parallel
  target that compiles the same sources with -fPIC and links them into
- libsonlib.so.1.1.0 (soname libsonlib.so.1).  Quicktree symbols are left
- unresolved: libquicktree is a static, non-PIC library that cannot be
- embedded in a shared object, so consumers must link -lquicktree (as they
- must for the static library); this exports the quicktree symbols into the
- executable's dynamic symbol table where this library resolves them at run
- time.
+ libsonlib.so.1.1.0 (soname libsonlib.so.1).  The shared library is linked
+ against the shared libquicktree so that the TreeREP symbols
+ (neighbour_joining_buildtree and friends) are resolved at run time and
+ consumers do not have to add -lquicktree themselves.  The static archive
+ still leaves these symbols unresolved, so static consumers keep linking
+ -lquicktree.
 Author: Andreas Tille <tille at debian.org>
 Forwarded: no
-Last-Update: 2026-10-21
+Last-Update: 2026-11-06
 Assisted-By: scaleway/deepseek-v4-flash-0731
+Assisted-By: deepseek-v4.1-flash-free
 
 --- a/C/Makefile
 +++ b/C/Makefile
@@ -27,17 +28,15 @@ Assisted-By: scaleway/deepseek-v4-flash-0731
  
  ${binPath}/sonLibTests : ${libTests} ${libInternalHeaders} ${libPath}/sonLib.a ${libPath}/cuTest.a tests/allTests.c
  	@mkdir -p $(dir $@)
-@@ -57,5 +57,31 @@ ${libPath}/sonLib.a : ${libSources} ${cp
+@@ -57,5 +57,29 @@ ${libPath}/sonLib.a : ${libSources} ${cp
  	rm *.o
  	mv sonLib.a ${libPath}/
  
-+# Shared library (libsonlib.so.1.1.0, soname libsonlib.so.1).  Quicktree
-+# symbols are intentionally left unresolved here: libquicktree is a
-+# static, non-PIC library that cannot be embedded in a shared object, so
-+# consumers must link -lquicktree themselves (as they must for the static
-+# library).  When a consumer does so, the quicktree symbols end up in the
-+# executable's dynamic symbol table and this library resolves them at run
-+# time.
++# Shared library (libsonlib.so.1.1.0, soname libsonlib.so.1).  Link the
++# shared libquicktree so that the TreeREP symbols (neighbour_joining_buildtree
++# and friends) are resolved at run time and consumers do not have to add
++# -lquicktree themselves.  The static archive still leaves them unresolved,
++# so static consumers keep linking -lquicktree.
 +soObjDir = obj
 +soCSources = $(wildcard impl/*.c)
 +soCppSources = $(wildcard impl/*.cpp)
@@ -54,7 +53,7 @@ Assisted-By: scaleway/deepseek-v4-flash-0731
 +
 +${libPath}/libsonlib.so.1.1.0 : ${soCObjFiles} ${soCppObjFiles} ${libInternalHeaders}
 +	@mkdir -p $(dir $@)
-+	${cpp} -shared -Wl,-soname,libsonlib.so.1 $(LDFLAGS) -o $@.tmp ${soCObjFiles} ${soCppObjFiles} ${dblibs}
++	${cpp} -shared -Wl,-soname,libsonlib.so.1 $(LDFLAGS) -o $@.tmp ${soCObjFiles} ${soCppObjFiles} ${dblibs} -lquicktree
 +	mv $@.tmp $@
 +
  test:



View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/compare/75c2f77d3c450940916483a75a25c44e93d6c0c1...d7e3ee71261d30a41aed8867c30c54bd402696e3

-- 
View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/compare/75c2f77d3c450940916483a75a25c44e93d6c0c1...d7e3ee71261d30a41aed8867c30c54bd402696e3
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261106/789f3c6d/attachment-0001.htm>


More information about the debian-med-commit mailing list