[tex-live] Build failure on Mac OS X 10.4.7: dvipng

Jonathan Kew jonathan_kew at sil.org
Fri Dec 8 00:59:25 CET 2006


On my Mac OS X 10.4.7 (Intel and PPC) systems, ./Build ends with a  
link failure in dvipng:

gcc  dvipng.o color.o draw.o dvi.o font.o misc.o pk.o set.o special.o  
papersiz.o ppagelist.o vf.o t1.o sfd.o ft.o enc.o fontmap.o tfm.o -o  
dvipng -lm ../kpathsea/.libs/libkpathsea.a  ../../libs/gd/ 
libgd.a ../../libs/freetype2/.libs/libfreetype.a ../../libs/t1lib/ 
libt1.a ../../libs/t1lib/../type1/libtype1.a ../../libs/libpng/ 
libpng.a ../../libs/zlib/libz.a
/usr/bin/ld: multiple definitions of symbol _hash_create
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libm.dylib(strhash.So)  
definition of _hash_create
../kpathsea/.libs/libkpathsea.a(hash.o) definition of _hash_create in  
section (__TEXT,__text)
collect2: ld returned 1 exit status
make[2]: *** [dvipng] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1


This occurs because there is a hash_create in the system's libm,  
which clashes with the function defined in kpathsea, and the system's  
dynamic libm is linked before the static kpathsea library.

The problem will not arise if libkpathsea.a is listed *before* -lm in  
the link command. However, a further problem then shows up: there are  
a bunch of unresolved references to Mac OS X functions. I believe  
these are coming from libfreetype, which uses Mac APIs to interact  
with the OS font system. To resolve these references, we need to add  
"-framework ApplicationServices" to the link command.

So I'd like to propose the following patch to texk/dvipng/ 
configure.ac (and the resulting update to texk/dvipng/configure,  
after re-running autoconf in that directory):

===================================================================
--- texk/dvipng/configure.ac    (revision 2611)
+++ texk/dvipng/configure.ac    (working copy)
@@ -167,11 +167,6 @@
  sinclude(../../libs/freetype2/freetype2.ac)
  sinclude(../kpathsea/withenable.ac)
-LIBS="../kpathsea/.libs/libkpathsea.a $LIBS"
-AC_DEFINE(HAVE_KPATHSEA_KPATHSEA_H)
-AC_DEFINE(HAVE_KPSE_ENC_FORMATS)
-AC_DEFINE(HAVE_LIBKPATHSEA)
-
  dnl -- gd jpeg fn not defined? AC_DEFINE(HAVE_GDIMAGECREATETRUECOLOR)
  dnl then we get a warning about gdImageAlpha, but so what.
  AC_DEFINE(HAVE_GDIMAGEPNGEX)
@@ -189,6 +184,33 @@
  AC_CHECK_LIB(m, main)
  AC_CHECK_LIB(gen, basename)
+LIBS="../kpathsea/.libs/libkpathsea.a $LIBS"
+AC_DEFINE(HAVE_KPATHSEA_KPATHSEA_H)
+AC_DEFINE(HAVE_KPSE_ENC_FORMATS)
+AC_DEFINE(HAVE_LIBKPATHSEA)
+
+#
+#   Check for ApplicationServices
+#
+AC_DEFUN([AC_HAS_APP_SERVICES], [
+  _cppflags=$CPPFLAGS _ldflags=$LDFLAGS
+  AC_MSG_CHECKING([for Mac OS X ApplicationServices framework])
+  AC_TRY_COMPILE(
+    [
+#include <ApplicationServices/ApplicationServices.h>
+      ], [
+ATSFontRef fontRef;
+    ],
+    [ AC_MSG_RESULT(yes)
+      AC_DEFINE(HAVE_APP_SERVICES, 1, [Define if you have  
ApplicationServices (Mac OS X)])
+      LIBS="$LIBS -framework ApplicationServices"
+    ],
+    [ AC_MSG_RESULT(no) ]
+  )
+])
+
+AC_HAS_APP_SERVICES
+
  AC_CONFIG_HEADERS([config.h])
  AC_CONFIG_FILES(Makefile)
  AC_OUTPUT
===================================================================

The effect is to move libkpathsea.a earlier in LIBS, so it is found  
before libm, and to test for the existence of the Mac OS X  
ApplicationServices framework and add this to the link if present.

This will allow a successful build on current Mac OS X systems, and  
should be harmless elsewhere; if I don't hear objections, I intend to  
check it in tomorrow after some further testing here.

JK



More information about the tex-live mailing list