Page 1 of 1

libpng doesn't build as shared library: inter-library deps

Posted: Tue Nov 29, 2016 3:37 pm
by mariuszp
I pass the --disable-static option when cross-compling libpng for my OS, but regardless, it build only the static library. During linking, libtool prints the following message:

Code: Select all

/bin/bash ./libtool  --tag=CC   --mode=link x86_64-glidix-gcc  -g -O2 -no-undefined -export-dynamic -version-number 16:21:0  -Wl,--version-script=libpng.vers   -o libpng16.la -rpath /usr/lib png.lo pngerror.lo pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo pngwrite.lo pngwtran.lo pngwutil.lo    -lz -lm 

*** Warning: inter-library dependencies are not known to be supported.
*** All declared inter-library dependencies are being dropped.
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.
Why does it think inter-library dependencies are not supported? And why is it passing -no-undefined anyway?

Is there any way I can configure it to know that inter-library dependencies work on my OS and therefore it can build the shared library?

EDIT: I have also edited the "configure" script, specifically the part that decides whether a dynamic linker is available (otherwise it complains that one doesn't exist, and decides that building shared libs is impossible), by adding the following rule:

Code: Select all

glidix*)
  version_type=linux
  need_lib_prefix=no
  need_version=no
  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
  dynamic_linker='Glidix dynld'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  hardcode_into_libs=yes
  ;;
I set "version_type" to linux because a lot of rules for different operating systems had that.
Do I perhaps have to set something here? Or is it elsewhere?

Re: libpng doesn't build as shared library: inter-library de

Posted: Fri Dec 02, 2016 2:09 am
by klange
Hey mariuszp, I just ran into this same issue trying to build freetype and I think I've got a solution for you: There's a lot more places you'll need to tell libtool about your OS's dynamic linking. I was reading through some patches in Pedigree to see what was happening there. You can install your own libtool with a patched libtool.m4 (with all of those patches) and re-run autoconf and libtoolize on the package and it should work, or edit the relevant configure script directly (probably the same one you already edited).

Re: libpng doesn't build as shared library: inter-library de

Posted: Fri Dec 02, 2016 4:56 am
by mariuszp
Yeah, i just figured out i can do this by editing the configure script. Thanks for trlling me about libtool.m4 though, i will patch that to avoid repeating the process constantly later.

Re: libpng doesn't build as shared library: inter-library de

Posted: Tue Feb 18, 2020 3:38 am
by max
Sorry for digging out this old thread :P

Unfortunately the patch you linked @klange is no longer there.. I'm facing the same issue, when building libpng it says:

Code: Select all

    checking if libtool supports shared libraries... no
    checking whether to build shared libraries... no
Therefore I don't get any .so files generated. I've configured it simply with --host=i686-ghost and patched the config.sub to accept my system type. But how must I edit the libtool config so it understands how to link for my OS?

Thanks in advance!!

EDIT: Tried it by editing the configure file by hand, this works.. but what would be the autoconf way of achieving this?

Re: libpng doesn't build as shared library: inter-library de

Posted: Wed Feb 19, 2020 12:31 am
by Korona
Here is a working patch: https://github.com/managarm/bootstrap-m ... tics.patch. The same dir also has a patch that fixes libtool's --with-sysroot that I highly recommend to avoid problems where host libs get linked into target binaries.

Patch libtool and autoreconf the target package. Usually, there is a autogen.sh script to call autoreconf for you. You can also look at Managarm's bootstrap.yml for libpng's build process in particular: https://github.com/managarm/bootstrap-m ... p.yml#L969.

Re: libpng doesn't build as shared library: inter-library de

Posted: Wed Feb 19, 2020 10:13 am
by max
Hey Korona,

very nice thanks for the links. Maybe we could add this somewhere to the OSDev wiki if someones looking for it.

Greets

Re: libpng doesn't build as shared library: inter-library de

Posted: Wed Feb 19, 2020 11:21 am
by Korona
Feel free to steal my libtool patch (under any license of your choice) and add info on how use it to the wiki!