libgphoto2 builds lacks a link to the math library in all Ubuntu releases since at least Xenial 16.04

Bug #1802674 reported by Pascal Mons
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libgphoto2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Background:
With all recent versions of GCC on GNU/Linux systems like Ubuntu, when you use the math library, you have to explicitly link to it.

I am currently using Xenial 16.04 and did a recompile of source package libgphoto2. Then I got warnings fromdpkg-shlibdeps.

make[1]: Entering directory '/home/ubuntu-xenial/user/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
dh_shlibdeps -ldebian/libgphoto2-6/usr/lib/:debian/libgphoto2-port12/usr/lib/
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/ptp2.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: 2 other similar warnings have been skipped (use -v to see them all)
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/stv0680.so contains an unresolvable reference to symbol pow: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/sonix.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/jl2005c.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/digigr8.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/mars.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/sierra.so contains an unresolvable reference to symbol roundf: it's probably a plugin
make[1]: Leaving directory '/home/ubuntu-xenial/user/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'

I am quite sure that sqrt is the square root function from the math library. Usually, at least with GCC version newer than ~ 2013 you have to append a -lm to link against the math library. Obviously this isn't the case:

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I.. -I../libgphoto2_port -I../libgphoto2_port -D_GPHOTO2_INTERNAL_CODE -DLOCALEDIR=\"/usr/share/locale\" -DCAMLIBS=\"/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9\" -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/libexif -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wmissing-declarations -Wmissing-prototypes -c gphoto2-filesys.c -fPIC -DPIC -o .libs/libgphoto2_la-gphoto2-filesys.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I.. -I../libgphoto2_port -I../libgphoto2_port -D_GPHOTO2_INTERNAL_CODE -DLOCALEDIR=\"/usr/share/locale\" -DCAMLIBS=\"/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9\" -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/libexif -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wmissing-declarations -Wmissing-prototypes -c gphoto2-filesys.c -fPIE -o libgphoto2_la-gphoto2-filesys.o >/dev/null 2>&1

at the end we should see

-c gphoto2-filesys.c -fPIE -lm -o libgphoto2_la-gphoto2-filesys.o >/dev/null 2>&1

I did check in the official Ubuntu repository and you did get the same warnings:

dh_shlibdeps -ldebian/libgphoto2-6/usr/lib/:debian/libgphoto2-port12/usr/lib/
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/jl2005c.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/sierra.so contains an unresolvable reference to symbol roundf: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/ptp2.so contains an unresolvable reference to symbol log2: it's probably a plugin
dpkg-shlibdeps: warning: 2 other similar warnings have been skipped (use -v to see them all)
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/digigr8.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/mars.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/sonix.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/stv0680.so contains an unresolvable reference to symbol pow: it's probably a plugin
make[1]: Leaving directory '/«PKGBUILDDIR»'

It looks like the switch from GCC to NOT automatically link the math library was never dealt with, even in the latest Ubuntu releases ...

I am no a configure.ac specialist and don't know exactly what to do in debian/rules to correct the problem.

Either way may be upstream developers should be warned of the problem since they are in charge of maintaining the configure.ac file ...

Here is some hint about what to do:
https://www.gnu.org/software/automake/manual/html_node/Linking.html

There is still the pow function ... and I don't know exactly if it's part of the math library ? But it should be coming from another library if so which as well should be linked.

Besides it's still the same in the latest version of gphoto2 PROPOSED for Bionic 18.04:

amd64 build of libgphoto2 2.5.16-2 in ubuntu bionic PROPOSED
https://launchpad.net/ubuntu/+source/libgphoto2/2.5.16-2/+build/14176152

dh_shlibdeps -ldebian/libgphoto2-6/usr/lib/:debian/libgphoto2-port12/usr/lib/
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/ptp2.so contains an unresolvable reference to symbol log2: it's probably a plugin
dpkg-shlibdeps: warning: 2 other similar warnings have been skipped (use -v to see them all)
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/digigr8.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/konica_qm150.so contains an unresolvable reference to symbol exif_data_unref: it's probably a plugin
dpkg-shlibdeps: warning: 1 similar warning has been skipped (use -v to see it)
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/mars.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/sierra.so contains an unresolvable reference to symbol roundf: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/jl2005c.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/sonix.so contains an unresolvable reference to symbol sqrt: it's probably a plugin
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/stv0680.so contains an unresolvable reference to symbol pow: it's probably a plugin
make[1]: Leaving directory '/<<PKGBUILDDIR>>'

It seems you have even more math functions ignored like log2 ...

I know for sure that Ubuntu only copy these builds from Debian ... However it's urgent not to overlook GCC evolution impacts on basic packages ...

Tags: linking
Revision history for this message
Pascal Mons (anton+) wrote :

pow is indeed part as well of the math library for the 'power of' function.
as well as roundf.

Revision history for this message
Pascal Mons (anton+) wrote :

Well, I did find a working fix to apply in debian/rules.

# Add missing math libraray for linking in gphoto2
# (automatic math library linking was dropped by GCC years ago)
export DEB_LDFLAGS_MAINT_APPEND := -lm

I did add as well all available processor cores in parallel build, and Optimization O3 instead of -O2.

However it would better if upstream would update its own configure.ac file ...

Here is the portion of the log showing no sign of unresolved dependencies:

make[1]: Leaving directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
   debian/rules override_dh_makeshlibs
make[1]: Entering directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
dh_makeshlibs -plibgphoto2-6 -X/usr/lib/x86_64-linux-gnu/libgphoto2/
dh_makeshlibs -plibgphoto2-port12 -X/usr/lib/x86_64-linux-gnu/libgphoto2_port/
make[1]: Leaving directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
   debian/rules override_dh_shlibdeps
make[1]: Entering directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
dh_shlibdeps -ldebian/libgphoto2-6/usr/lib/:debian/libgphoto2-port12/usr/lib/
make[1]: Leaving directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
   dh_installdeb -O--parallel
   debian/rules override_dh_gencontrol
make[1]: Entering directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
dh_gencontrol
dpkg-gencontrol: warning: Depends field of package libgphoto2-port12-dbgsym: unknown substitution variable ${shlibs:Depends}
dpkg-gencontrol: warning: Depends field of package libgphoto2-6-dbgsym: unknown substitution variable ${shlibs:Depends}
dh_gencontrol -plibgphoto2-6 -- -Vudev-hotplug='udev (>= 201)'
make[1]: Leaving directory '/home/ubuntu-xenial/pascal/Downloads/Launchpad/libgphoto2/libgphoto2-2.5.9'
   dh_md5sums -O--parallel
   dh_builddeb -O--parallel

It would be nice for Ubuntu to update the build in all supported releases.

The rebuild will be available in my PPA soon:
https://launchpad.net/~anton+/+archive/ubuntu/photo-video-apps

However beware that this PPA is yet NOT to be added on any system as it's still unstable and miss some dependencies i.e. if installing a package you will be faced with a partial upgrade which in turn will remove some of your already installed apps.

affects: mtpaint (Ubuntu) → libgphoto2 (Ubuntu)
Revision history for this message
Pascal Mons (anton+) wrote :

Well, my Launchpad PPA is currently back to fully working.

After rebuilding libgphoto2 2.5.16 (the Bionic 18.04 version) I found another missing library link:

dh_shlibdeps -ldebian/libgphoto2-6/usr/lib/:debian/libgphoto2-port12/usr/lib/
dpkg-shlibdeps: warning: debian/libgphoto2-6/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.16/konica_qm150.so contains an unresolvable reference to symbol exif_data_new_from_data: it's probably a plugin
dpkg-shlibdeps: warning: 1 similar warning has been skipped (use -v to see it)

That's the libexif library here missing in the build.

I did update anew my debian/rules files in my PPA, since I did a backport of this version for Xenial 16.04.

A side note here is that the debian/rules file looks poorly maintained by Debian.

They apparently add libraries link by editing the CFLAGS and CXXFLAGS ... Though there is dedicated commands to do so.

They missed as well a:

include /usr/share/dpkg/buildflags.mk

and the fully functional --parallel build with the right parameters.

tested with -j12 (processor cores) and working.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.