Bug 195743 - print/cups-base: undefined reference to `avahi_XXX`
Summary: print/cups-base: undefined reference to `avahi_XXX`
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-06 13:44 UTC by O. Hartmann
Modified: 2015-01-04 18:20 UTC (History)
6 users (show)

See Also:


Attachments
cups-base config.log (151.66 KB, text/plain)
2015-01-03 18:10 UTC, rkoberman
no flags Details
cups-base config.h (10.72 KB, text/plain)
2015-01-03 18:10 UTC, rkoberman
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2014-12-06 13:44:59 UTC
Building print/cups-base from scratch on CURRENT (FreeBSD 11.0-CURRENT #1 r275565: Sat Dec  6 13:17:31 CET 2014 amd64)results in the following error.

It doesnt matter whether AVAHI or mDNSResponder is configured - make rmconfig and followed by configuring eithr or one of the options results in the same error.

[...]
cc -L../cgi-bin -L../cups -L../filter -L../ppdc -L../scheduler -L/usr/local/lib -Wl,-rpath,/usr/lib:/usr/local/lib -fstack-protector -Wl,-R/usr/local/lib   -Wall -Wno-format-y2k -Wunused -fPIC -Os -g -fstack-protector -Wno-tautological-compare -o ipptool-static ipptool.o  ../cups/libcups.a \
         -lssl -lcrypto -ldns_sd -pthread -lm -lcrypt   -lz -lz
../cups/libcups.a(http-support.o): In function `_httpResolveURI':
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1739: undefined reference to `avahi_simple_poll_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1741: undefined reference to `avahi_simple_poll_set_func'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1743: undefined reference to `avahi_simple_poll_get'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1743: undefined reference to `avahi_client_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1747: undefined reference to `avahi_service_resolver_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1758: undefined reference to `avahi_simple_poll_iterate'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1768: undefined reference to `avahi_service_resolver_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1776: undefined reference to `avahi_simple_poll_iterate'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1800: undefined reference to `avahi_client_free'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1803: undefined reference to `avahi_simple_poll_free'
../cups/libcups.a(http-support.o): In function `http_client_cb':
Comment 1 Raphael Kubo da Costa freebsd_committer 2015-01-03 16:28:32 UTC
I'm unable to reproduce it here -- if I choose the MDNSRESPONDER option (which is on by default if you `make rmconfig'), Avahi support is disabled and that part of the code in http-support.c is not built.

Do you have any avahi ports installed? Can you show what `make showconfig' outputs for you, as well as `make -V CONFIGURE_ARGS'?
Comment 2 Loïc Bartoletti freebsd_committer 2015-01-03 17:35:37 UTC
Same error :

	 -lssl -lcrypto -ldns_sd -pthread -lm -lcrypt   -lz -lz
../cups/libcups.a(http-support.o): In function `_httpResolveURI':
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1739: undefined reference to `avahi_simple_poll_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1741: undefined reference to `avahi_simple_poll_set_func'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1743: undefined reference to `avahi_simple_poll_get'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1743: undefined reference to `avahi_client_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1747: undefined reference to `avahi_service_resolver_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1758: undefined reference to `avahi_simple_poll_iterate'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1768: undefined reference to `avahi_service_resolver_new'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1776: undefined reference to `avahi_simple_poll_iterate'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1800: undefined reference to `avahi_client_free'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1803: undefined reference to `avahi_simple_poll_free'
../cups/libcups.a(http-support.o): In function `http_client_cb':
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:1871: undefined reference to `avahi_simple_poll_quit'
../cups/libcups.a(http-support.o): In function `http_resolve_cb':
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:2234: undefined reference to `avahi_service_resolver_free'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:2277: undefined reference to `avahi_string_list_find'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:2288: undefined reference to `avahi_string_list_find'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:2290: undefined reference to `avahi_string_list_get_pair'
/usr/ports/print/cups-client/work/cups-1.7.3/cups/http-support.c:2379: undefined reference to `avahi_simple_poll_quit'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:192 : la recette pour la cible « ippserver » a échouée
gmake[3]: *** [ippserver] Erreur 1
gmake[3]: *** Attente des tâches non terminées....
gmake[3] : on quitte le répertoire « /usr/ports/print/cups-base/work/cups-1.7.3/test »
Makefile:31 : la recette pour la cible « all » a échouée
gmake[2]: *** [all] Erreur 1
gmake[2] : on quitte le répertoire « /usr/ports/print/cups-base/work/cups-1.7.3 »
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/print/cups-base
*** Error code 1

Stop.
make: stopped in /usr/ports/print/cups-base
bureau% sudo make -C /usr/ports/print/cups-base -V CONFIGURE_ARGS
--localstatedir=/var			 --disable-gssapi			 --with-cups-user=cups		 --with-cups-group=cups		 --with-system-groups=wheel	 --with-docdir=/usr/local/share/doc/cups		 --with-menudir=/usr/local/share/applications		 --with-domainsocket=/var/run/cups.sock	 --with-cachedir=/var/db/cups	 --with-pam-module="unix"		 --enable-ssl --with-printcap=/usr/local/etc/printcap --disable-gnutls --enable-openssl --enable-libpaper --with-dnssd-includes=/usr/local/include --disable-avahi --disable-pam --disable-dbus --disable-libusb --with-icondir=/usr/local/share/icons --prefix=/usr/local ${_LATE_CONFIGURE_ARGS}
bureau% sudo make -C /usr/ports/print/cups-base showconfig       
===> The following configuration options are available for cups-base-1.7.3_4:
     DBUS=off: D-Bus IPC system support
     ICONS=on: Desktop icons
     LIBPAPER=on: Paper size selection support via libpaper
     LIBUSB=off: USB support
     PAM=off: Pluggable authentication module support
     XDG_OPEN=off: Build with XDG_OPEN as browser
====> Interpreters for web interfaces
     JAVA=off: Java platform support
     PERL=off: Perl scripting language support
     PHP=off: PHP bindings or support
     PYTHON=off: Python bindings or support
====> SSL protocol support: you have to select exactly one of them
     GNUTLS=off: SSL/TLS support via GnuTLS
     OPENSSL=on: SSL/TLS support via OpenSSL
====> Zeroconf support: you can only select none or one of them
     AVAHI=off: Zeroconf support via Avahi
     MDNSRESPONDER=on: Zeroconf support via mDNSResponder
===> Use 'make config' to modify these settings
Comment 3 Raphael Kubo da Costa freebsd_committer 2015-01-03 17:55:48 UTC
It still works fine here and I've just tried it on Poudriere as well. Which avahi ports do you have installed, if any? Can you attach the output of `make configure' and the generated config.log and config.h to the bug?
Comment 4 rkoberman 2015-01-03 18:10:16 UTC
Created attachment 151296 [details]
cups-base config.log
Comment 5 rkoberman 2015-01-03 18:10:59 UTC
Created attachment 151297 [details]
cups-base config.h
Comment 6 Raphael Kubo da Costa freebsd_committer 2015-01-03 19:09:35 UTC
Hmm, those logs look just fine as well (HAVE_AVAHI is not defined in config.h, and configure did not even look for Avahi).

What does the compiler command line look like when building http-support.c? I can only think of another config.h being used instead of the one in cups.
Comment 7 Martin Birgmeier 2015-01-03 19:48:52 UTC
Could it be because the cups-client port produces a /usr/local/lib/libcups.so.2 file which links against avahi?

/usr/local/lib/libcups.so.2:
        libssl.so.7 => /usr/lib/libssl.so.7 (0x801675000)
        libcrypto.so.7 => /lib/libcrypto.so.7 (0x8018e0000)
        libavahi-common.so.3 => /usr/local/lib/libavahi-common.so.3 (0x801cd5000)
        libavahi-client.so.3 => /usr/local/lib/libavahi-client.so.3 (0x801ee1000)
        libm.so.5 => /lib/libm.so.5 (0x8020f0000)
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x802318000)
        libz.so.6 => /lib/libz.so.6 (0x802538000)
        libthr.so.3 => /lib/libthr.so.3 (0x80274e000)
        libc.so.7 => /lib/libc.so.7 (0x80081f000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x802973000)
        libdbus-1.so.3 => /usr/local/lib/libdbus-1.so.3 (0x802b7e000)

Also some of the other cups ports produce libraries which reference avahi, e.g., cups-image, cups-filters.

Also, doing a 'make' in /usr/ports/print/cups-base produces libcups.* which link against avahi:

...
make[1]: stopped in /.../hal/z/SRC/FreeBSD-ports/head/print/cups-base
*** Error code 1

Stop.
make: stopped in /.../hal/z/SRC/FreeBSD-ports/head/print/cups-base
[0]# pushd /usr/tmp/ports/print/cups-base/work/cups-1.7.3
/usr/tmp/ports/print/cups-base/work/cups-1.7.3 /usr/ports/print/cups-base
[0]# ldd cups/libcups.so.2 
cups/libcups.so.2:
        libssl.so.7 => /usr/lib/libssl.so.7 (0x801675000)
        libcrypto.so.7 => /lib/libcrypto.so.7 (0x8018e0000)
        libavahi-common.so.3 => /usr/local/lib/libavahi-common.so.3 (0x801cd5000)
        libavahi-client.so.3 => /usr/local/lib/libavahi-client.so.3 (0x801ee1000)
        libm.so.5 => /lib/libm.so.5 (0x8020f0000)
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x802318000)
        libz.so.6 => /lib/libz.so.6 (0x802538000)
        libthr.so.3 => /lib/libthr.so.3 (0x80274e000)
        libc.so.7 => /lib/libc.so.7 (0x80081f000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x802973000)
        libdbus-1.so.3 => /usr/local/lib/libdbus-1.so.3 (0x802b7e000)
[0]# nm cups/libcups.a | egrep ':$|avahi'
adminutil.o:
array.o:
attr.o:
auth.o:
backchannel.o:
backend.o:
conflicts.o:
custom.o:
debug.o:
dest.o:
                 U avahi_client_free
                 U avahi_client_new
                 U avahi_record_browser_free
                 U avahi_record_browser_new
                 U avahi_service_browser_free
                 U avahi_service_browser_new
                 U avahi_service_name_join
                 U avahi_simple_poll_free
                 U avahi_simple_poll_get
                 U avahi_simple_poll_iterate
                 U avahi_simple_poll_new
                 U avahi_simple_poll_quit
                 U avahi_simple_poll_set_func
dest-job.o:
dest-localization.o:
dest-options.o:
dir.o:
emit.o:
encode.o:
file.o:
getdevices.o:
getifaddrs.o:
getputfile.o:
globals.o:
http.o:
http-addr.o:
http-addrlist.o:
http-support.o:
                 U avahi_client_free
                 U avahi_client_new
                 U avahi_service_resolver_free
                 U avahi_service_resolver_new
                 U avahi_simple_poll_free
                 U avahi_simple_poll_get
                 U avahi_simple_poll_iterate
                 U avahi_simple_poll_new
                 U avahi_simple_poll_quit
                 U avahi_simple_poll_set_func
                 U avahi_string_list_find
                 U avahi_string_list_get_pair
ipp.o:
ipp-support.o:
langprintf.o:
language.o:
localize.o:
mark.o:
md5.o:
md5passwd.o:
notify.o:
options.o:
page.o:
ppd.o:
ppd-cache.o:
pwg-media.o:
request.o:
sidechannel.o:
snmp.o:
snprintf.o:
string.o:
tempfile.o:
thread.o:
transcode.o:
usersys.o:
util.o:
[0]#
Comment 8 Martin Birgmeier 2015-01-03 19:51:56 UTC
In /usr/ports/print/cups-base/Makefile, the following lines look fishy:

.if !defined(CUPS_CLIENT)
pre-build:
        ${CP} -p ${LOCALBASE}/lib/libcups.a ${WRKSRC}/cups/
        ${CP} -p ${LOCALBASE}/lib/libcups.so ${WRKSRC}/cups/
        ${CP} -p ${LOCALBASE}/lib/libcups.so.2 ${WRKSRC}/cups/
.if !defined(CUPS_IMAGE)
        ${CP} -p ${LOCALBASE}/lib/libcupsimage.so ${WRKSRC}/filter/
        ${CP} -p ${LOCALBASE}/lib/libcupsimage.so.2 ${WRKSRC}/filter/
.endif
.endif
Comment 9 Raphael Kubo da Costa freebsd_committer 2015-01-03 20:24:50 UTC
Nice investigative work, Martin :-)

That seems to be the cause indeed. cups-client does not have the same options as cups-base, the Avahi/mDNSResponder-related arguments are not passed to the configure script so the port ends up picking Avahi automatically if it happens to be present on the system. After rebuilding cups-client with avahi-app installed here I was finally able to reproduce the problem.
Comment 10 rkoberman 2015-01-03 20:55:54 UTC
Here is the compile command:
cc -L../cgi-bin -L../cups -L../filter -L../ppdc -L../scheduler -L/usr/local/lib -Wl,-rpath,/usr/lib:/usr/local/lib -fstack-protector -Wl,-R/usr/local/lib   -Wall -Wno-format-y2k -Wunused -fPIC -Os -g -fstack-protector -Wno-tautological-compare -o ippserver ippserver.o  ../cups/libcups.a \
	 -lssl -lcrypto -ldns_sd -pthread -lm -lcrypt   -lz -lz
Comment 11 Kurt Jaeger freebsd_committer 2015-01-04 08:37:12 UTC
Boris Samorodov suggests a patch in

https://lists.freebsd.org/pipermail/freebsd-ports/2015-January/097370.html

which is tested by Kevin Oberman (with a small change) and seems to work.
Comment 12 commit-hook freebsd_committer 2015-01-04 13:50:54 UTC
A commit references this bug:

Author: bsam
Date: Sun Jan  4 13:50:42 UTC 2015
New revision: 376233
URL: https://svnweb.freebsd.org/changeset/ports/376233

Log:
  print/cups-client via print/cups-base: treat avahi/dnssd explicitely

  1. The port's configure script is auto-detecting if avahi exists
  (unless avahi is explicitely disabled):
  ---
     9096 if test "x$PKGCONFIG" != x -a x$enable_avahi != xno; then
     9097         { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Avahi" >&5
     9098 $as_echo_n "checking for Avahi... " >&6; }
     9099         if $PKGCONFIG --exists avahi-client; then
     9100                 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
     9101 $as_echo "yes" >&6; }
  ---

  So if avahi-lib is installed one get config.log:
  ---
  configure:9097: checking for Avahi
  configure:9100: result: yes
  [...]
  #define HAVE_AVAHI 1
  ---

  And later avahi is used while building:
  ---
  Using LIBS=-lcups  -lssl -lcrypto -L/usr/local/lib -lavahi-common -lavahi-client   -lz -pthread -lm -lcrypt   -lz
  ---

  Then print/cups-client installs libraries which are linked with avahi, ex.:
  ---
  % ldd libcups.so | grep avahi
          libavahi-common.so.3 => /usr/local/lib/libavahi-common.so.3 (0x801cda000)
          libavahi-client.so.3 => /usr/local/lib/libavahi-client.so.3 (0x801ee6000)
  ---

  Which leads to print/cups-base build failure (even if avahi is unset by options):
  ---
  Linking ippserver...
  cc -L../cgi-bin -L../cups -L../filter -L../ppdc -L../scheduler -L/usr/local/lib -Wl,-rpath,/usr/lib:/usr/local/lib -fstack-protector -Wl,-R/usr/local/lib   -Wall -Wno-format-y2k -Wunused -fPIC -Os -g -fstack-protector -Wno-tautological-compare -o ippserver ippserver.o  ../cups/libcups.a \
           -lssl -lcrypto -ldns_sd -pthread -lm -lcrypt   -lz -lz
  ../cups/libcups.a(http-support.o): In function `_httpResolveURI':
  ---

  Let's reflect this fact.

  2. Bump PORTREVISION for print/cups-client, it's default options and dependencies
  were changed.

  PR:		ports/195743
  Submitted by:	O. Hartmann <ohartman@zedat.fu-berlin.de>
  Discussed at:	ports@
  Tested by:	O. Hartmann <ohartman@zedat.fu-berlin.de>

Changes:
  head/print/cups-base/Makefile