gcc - linux linker: '-lpng' inhibits '-lz'? -


on ubuntu-13.04, got error when building executable shared libraries, using gcc-4.7.3 provided linux distribution.

i guess problem between libpng , zlib (the former uses latter), don't know why.

first, command is:

$ 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 

which gives following error:

/usr/local/lib/muesli/libfml.so: undefined reference `gzwrite' /usr/local/lib/muesli/libfml.so: undefined reference `gzopen' /usr/local/lib/muesli/libfml.so: undefined reference `gzclose' /usr/local/lib/muesli/libfml.so: undefined reference `gzread' collect2: error: ld returned 1 exit status 

but note -lz present. after that, added linker option --trace-symbol= in order more information:

$ 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 

which in turn gives results:

/usr/local/lib/muesli/libfml.so: reference 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 `gzwrite' /usr/local/lib/muesli/libfml.so: undefined reference `gzopen' /usr/local/lib/muesli/libfml.so: undefined reference `gzclose' /usr/local/lib/muesli/libfml.so: undefined reference `gzread' collect2: error: ld returned 1 exit status 

so, gzwrite found in libz.so linker don't use it!

by chance, thought remove -lpng option (actually, libpng library not used) , problem solved! why?

secondly, compile whole code version of gcc-4.7.3 (compiled myself -- used test many versions of compiler), , error didn't occur, using both -lpng , -lz!

any idea?

in addition, different try program (which use libpng) leads successful build.

edited on 2013-10-08

i'm pretty sure bug in ubuntu-13.04: i've tried 2 other linux distros (fedora 16 -- ubuntu-10.04) , linker behavior standard, not described above in first part of message.

i plan report problem on ubuntu community. regards.

edited on 2013-10-09

the bug has been reported https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1237270

two possible fixes (until ubuntu doesn't repair itself):

  1. try compile in libpng.a , libz.a static library (it can temporary solution, because static libs evil in cases).

  2. recompile libpng original source, , compile libz.a static herein.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -