Subject: pkg/29030: graphics/sane-backends link fails on MacOS X 10.1.x 10.2.x
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <jdbaker@mylinuxisp.com>
List: pkgsrc-bugs
Date: 01/21/2005 00:37:00
>Number:         29030
>Category:       pkg
>Synopsis:       graphics/sane-backends link fails on MacOS X 10.1.x 10.2.x
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 21 00:37:00 +0000 2005
>Originator:     John D. Baker
>Release:        N/A (MacOS X 10.2.8)
>Organization:
>Environment:
Darwin pm8500.technoskunk.fur 6.8 Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 PDT 2003; root:xnu/xnu-344.49.obj~2/RELEASE_PPC  Power Macintosh powerpc

>Description:
Some utility programs included with sane-backends fail to link
because they encounter multiple definitions of symbols found both
in system libraries and in a private library archive.  E.g.,

gcc -pipe -o .libs/scanimage scanimage.o stiff.o -framework CoreFoundation -framework IOKit  -L/Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib ../lib/liblib.a ../backend/.libs/libsane.dylib /Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib/libusb.dylib -lpthread -lm /Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib/libjpeg.dylib
ld: multiple definitions of symbol _getopt
/usr/lib/libpthread.dylib(getopt.So) definition of _getopt
../lib/liblib.a(getopt.o) definition of _getopt in section (__TEXT,__text)
ld: multiple definitions of symbol _opterr
/usr/lib/libpthread.dylib(getopt.So) definition of _opterr
../lib/liblib.a(getopt.o) definition of _opterr in section (__DATA,__data)
ld: multiple definitions of symbol _optind
/usr/lib/libpthread.dylib(getopt.So) definition of _optind
../lib/liblib.a(getopt.o) definition of _optind in section (__DATA,__data)
ld: multiple definitions of symbol _optopt
/usr/lib/libpthread.dylib(getopt.So) definition of _optopt
../lib/liblib.a(getopt.o) definition of _optopt in section (__DATA,__data)
gnumake[1]: *** [scanimage] Error 1
gnumake: *** [all-recursive] Error 1
*** Error code 2

Stop.
bmake: stopped in /usr/pkgsrc/graphics/sane-backends


Attempting to change the Makefile of the offending targets to omit
the local library and use only the system library results in additional
symbols being undefined:

gcc -pipe -o .libs/scanimage scanimage.o stiff.o -framework CoreFoundation -framework IOKit  -L/Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib ../backend/.libs/libsane.dylib /Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib/libusb.dylib -lpthread -lm /Volumes/NetBSD/tmp/pkgsrc/graphics/sane-backends/work/.buildlink/lib/libjpeg.dylib
ld: Undefined symbols:
_getopt_long
_md5_buffer
gnumake[1]: *** [scanimage] Error 1
gnumake: *** [all-recursive] Error 1
*** Error code 2

Stop.
bmake: stopped in /usr/pkgsrc/graphics/sane-backends


>How-To-Repeat:
On MacOS 10.1.x or 10.2.x with developer tools installed:

cd .../pkgsrc/graphics/sane-backends
bmake


>Fix:
This is probably not the right way to do this, but I've worked around
the problem by commenting out the symbols in the private library
source file as follows:

cd .../pkgsrc/graphics/sane-backends
bmake configure

--- work/sane-backends-1.0.15/lib/getopt.c.orig Thu Jan 20 17:43:15 2005
+++ work/sane-backends-1.0.15/lib/getopt.c      Thu Jan 20 17:44:50 2005
@@ -134,3 +134,3 @@
 /* 1003.2 says this must be 1 before any call.  */
-int optind = 1;
+/* int optind = 1; */
 
@@ -154,3 +154,3 @@
 
-int opterr = 1;
+/* int opterr = 1; */
 
@@ -160,3 +160,3 @@
 
-int optopt = '?';
+/* int optopt = '?'; */
 
@@ -1192,2 +1192,3 @@
 
+#if 0
 int
@@ -1203,2 +1204,3 @@
 }
+#endif /* 0 */
 

bmake install