linker: '-lpng' inhibits '-lz'

Bug #1237270 reported by EdouardC
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-defaults (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I got an error when building an executable from shared libraries, using GCC-4.7.3 provided by the linux distribution. I guess the problem is between libpng and zlib (the former uses the latter), but I don't know why. The following problem doesn't appear if I use a GCC version completely compiled by myself. Moreover, it doesn't occur on at least two other linux distros (Fedora 16 and ubuntu-10.04)
----------------------
Description: when I issue the command:
$ gfortran -o test_muesli_config_fml test_muesli_config_fml.o -fopenmp -Wl,--rpath,/usr/local/lib/muesli /usr/local/lib/muesli/libfml.so -lstdc++ -Wl,--rpath,/usr/lib /usr/lib/liblapack.so -Wl,--rpath,/usr/lib /usr/lib/libblas.so -lpng -lz -lpthread -lreadline -lhistory -Wl,--trace-symbol=gzwrite

I obtained the error:
/usr/local/lib/muesli/libfml.so: reference to gzwrite
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libz.so: definition of gzwrite
/usr/local/lib/muesli/libfml.so: undefined reference to `gzwrite'
/usr/local/lib/muesli/libfml.so: undefined reference to `gzopen'
/usr/local/lib/muesli/libfml.so: undefined reference to `gzclose'
/usr/local/lib/muesli/libfml.so: undefined reference to `gzread'
collect2: error: ld returned 1 exit status

If I remove the -lpng option (which is actually not used), the error disappear!

In addition, a different try with another program (which USE libpng) leads to a successful build.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: gcc 4:4.7.3-1ubuntu10
ProcVersionSignature: Ubuntu 3.8.0-31.46-generic 3.8.13.8
Uname: Linux 3.8.0-31-generic x86_64
ApportVersion: 2.9.2-0ubuntu8.3
Architecture: amd64
Date: Wed Oct 9 10:11:16 2013
InstallationDate: Installed on 2012-11-07 (335 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
MarkForUpload: True
SourcePackage: gcc-defaults
UpgradeStatus: Upgraded to raring on 2013-05-12 (149 days ago)

Revision history for this message
EdouardC (edouard-canot) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

This is an error in how your local libfml.so is linked. make sure that it is linked against libz.

Changed in gcc-defaults (Ubuntu):
status: New → Invalid
Revision history for this message
EdouardC (edouard-canot) wrote : Re: [Bug 1237270] Re: linker: '-lpng' inhibits '-lz'

Many thanks.

É. C.

--
Édouard Canot
IRISA/CNRS
+33 (0) 299 847 489
http://people.irisa.fr/Edouard.Canot

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.