Freetz / freetz

Freetz firmware extension/modification for the ​AVM FRITZ!Box series and devices with identical hardware
https://freetz.org
GNU General Public License v2.0
300 stars 160 forks source link

Make sure that sane is compiled with dl support #311

Closed martinkoehler closed 4 years ago

martinkoehler commented 4 years ago

In some configurations ./configure wrongly assumes that there is no dlopen support. This results in an undefined HAVE_DLOPEN in include/sane/config.h As a result HPLIP support, which needs dll does not work correctly This patch ensures that

define HAVE_DLOPEN 1

is set in the config.h

Note: I was unable to find a suitable ENV variable to ensure that dlopen is available. Note: This patch should also work if a system correctly has dlopen

er13 commented 4 years ago

Hmm, the following output is correct

configure:16362: checking for dlfcn.h
configure:16362: result: yes
configure:16367: checking for dlopen in -ldl
configure:16401: result: yes
configure:16411: checking for dlopen
configure:16411: result: no

checking for dlopen doesn't mean "checking for dlopen in general, in any library" but "checking for dlopen in libc". This is always so in autoconf generated tests. dlopen in uClibc resides in libdl and not in libc (at least in all uClibc versions currently supported in Freetz):

$ nm -D build/modified/filesystem/lib/libuClibc-1.0.14.so | grep dlopen

$ nm -D build/modified/filesystem/lib/libdl.so.1 | grep dlopen
00001b40 T dlopen

So please try to understand the logic checking for the symbol(s) like HAVE_DLOPEN and fix it instead.

martinkoehler commented 4 years ago

Dear Eugene, thanks. I agree that dlopen is there (via libdl) and probably I do not understand the logic of the symbols. As described in #310 and #300 I only discovered that I was unable to compile the libsane-dll.sowith dl support and without dl support all scanners supported by hplip do not work, since the sane backend can't load hplip. :-( Any ideas or help is appreciated. Thanks

er13 commented 4 years ago

It looks like I was wrong - the output is incorrect, at least for sane-backends

configure:16362: checking for dlfcn.h
configure:16362: result: yes
configure:16367: checking for dlopen in -ldl
configure:16401: result: yes
configure:16411: checking for dlopen
configure:16411: result: no

configure contains the following code, note the value of DL_LIBS and the value of LIBS right before the ac_cv_func_dlopen-check. This code comes from sane-backends-1.0.27/acinclude.m4

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
  DL_LIBS=-ldl
fi

       saved_LIBS="${LIBS}"
       LIBS="${LIBS} ${DL_LIBS}"
       for ac_func in dlopen
do :
  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
if test "x$ac_cv_func_dlopen" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_DLOPEN 1
_ACEOF
 enable_dynamic=yes
fi
done

       LIBS="${saved_LIBS}"

fi

done

So it looks like ac_cv_func_dlopen might mean both available in libc and available in general, either in libdl or in libc. In case of sane-backends it means the latter one.

martinkoehler commented 4 years ago

Solved with 2993312, 934c14d, b949032 by @er13