Bug 54948

Summary: Undefined symbols: "operator delete(void*)" "operator new(unsigned long)" "___cxa_pure_virtual"
Product: HarfBuzz Reporter: Ryan Schmidt <freedesktop>
Component: srcAssignee: Behdad Esfahbod <freedesktop>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: medium CC: amigadave, freedesktop, natanael.copa
Version: unspecified   
Hardware: Other   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: log of build failure from MacPorts

Description Ryan Schmidt 2012-09-15 03:28:38 UTC
Created attachment 67192 [details]
log of build failure from MacPorts

Hello, I'm the maintainer of harfbuzz in MacPorts. harfbuzz 0.9.4 does not build for me on OS X 10.8.1. 0.9.3 built fine.

The error shown is:


Undefined symbols for architecture x86_64:
  "operator delete(void*)", referenced from:
      CMAPMapper::~CMAPMapper() in libharfbuzz_la-hb-icu-le.o
      CMAPFormat4Mapper::~CMAPFormat4Mapper() in libhb_icu_le_la-cmaps.o
      CMAPGroupMapper::~CMAPGroupMapper() in libhb_icu_le_la-cmaps.o
      CMAPMapper::~CMAPMapper() in libhb_icu_le_la-cmaps.o
      FontTableCache::~FontTableCache() in libhb_icu_le_la-FontTableCache.o
      CMAPMapper::~CMAPMapper() in libhb_icu_le_la-PortableFontInstance.o
  "operator new(unsigned long)", referenced from:
      CMAPMapper::createUnicodeMapper(CMAPTable const*) in libhb_icu_le_la-cmaps.o
  "___cxa_pure_virtual", referenced from:
      vtable for CMAPMapper in libharfbuzz_la-hb-icu-le.o
      vtable for CMAPMapper in libhb_icu_le_la-cmaps.o
      vtable for FontTableCache in libhb_icu_le_la-FontTableCache.o
      vtable for CMAPMapper in libhb_icu_le_la-PortableFontInstance.o
ld: symbol(s) not found for architecture x86_64
Comment 1 Behdad Esfahbod 2012-09-15 18:35:32 UTC
I should make the icu-le backend optional.  We definitely don't want to build it by default.  I'll fix that this week and make a new release.
Comment 2 Ryan Schmidt 2012-09-15 18:53:28 UTC
FYI icu 4.8.1 is installed and harfbuzz 0.9.3 was successfully building with it, but 0.9.4 is not.
Comment 3 Ryan Schmidt 2012-10-04 05:47:12 UTC
FYI, upgrading icu to 49.1.2 did not help.
Comment 4 Natanael Copa 2012-10-26 15:12:05 UTC
I have a similar, related issue. libharfbuzz is built, but it has a reference to __cxa_pure_virtual bit is not linked to stdc++:

$ nm -D /usr/lib/libharfbuzz.so.0 | grep pure_virtual
         U __cxa_pure_virtual


The __cxa_pure_virtual is defined in libstdc++:
$ nm -D /usr/lib/libstdc\+\+.so.6 | grep pure_virtual
0004c6d0 T __cxa_pure_virtual


My first reaction was that we need link libharfbuzz with -lstdc++, but then I noticed this in configure.ac:

        # Make sure we don't link to libstdc++
        CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"

So I am a bit confused now...

The problem itself showed up for when building avahi after upgrading pango. from config.log:
configure:22042: checking for python module gtk

/usr/bin/python2.7: symbol '__cxa_pure_virtual': can't resolve symbol in lib '/usr/lib/libharfbuzz.so.0'.

/usr/bin/python2.7: symbol '_ZdlPv': can't resolve symbol in lib '/usr/lib/libharfbuzz.so.0'.
Comment 5 Natanael Copa 2012-10-27 08:33:26 UTC
(In reply to comment #4)
> /usr/bin/python2.7: symbol '__cxa_pure_virtual': can't resolve symbol in lib
> '/usr/lib/libharfbuzz.so.0'.

This definitively related icu. When compilini hrafbuzz without icu the problem goes away.

So currently, if icu is used, then harfbuzz should link with -libstdc++. I bet adding -lstdc++ would solve the issue on OSX too.
Comment 6 Ryan Schmidt 2012-10-30 08:53:57 UTC
Thank you, I confirmed that adding -lstdc++ fixed the harfbuzz 0.9.5 build on OS X. I tested on OS X 10.8.2 x86_64 and OS X 10.5.8 i386.
Comment 7 Claudio Saavedra 2012-12-09 10:19:43 UTC
I'm hitting something similar in a regular Fedora box:

make[3]: Entering directory `/home/claudio/git/gnome/harfbuzz/test/api'
  CCLD   test-blob
  CCLD   test-buffer
  CCLD   test-common
  CCLD   test-font
../../src/.libs/libharfbuzz.so: error: undefined reference to 'operator delete(void*)'
../../src/.libs/libharfbuzz.so: error: undefined reference to '__cxa_pure_virtual'
../../src/.libs/libharfbuzz.so: error: undefined reference to 'operator new(unsigned long)'
collect2: error: ld returned 1 exit status
make[3]: *** [test-blob] Error 1
Comment 8 Claudio Saavedra 2012-12-09 10:38:28 UTC
This is definitely not the right fix but it works it around for me:

diff --git a/src/Makefile.am b/src/Makefile.am
index b7896bf..5505cb1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -196,7 +196,7 @@ harfbuzz_def_dependency = harfbuzz.def
 libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
 else
 # Use a C linker, not C++; Don't link to libstdc++
-libharfbuzz_la_LINK = $(LINK) $(libharfbuzz_la_LDFLAGS)
+libharfbuzz_la_LINK = $(LINK) $(libharfbuzz_la_LDFLAGS) -lstdc++
 endif
 
 libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index c5a015f..2b05c80 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -8,7 +8,7 @@ MAINTAINERCLEANFILES =
 
 if HAVE_GLIB
 AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ -I$(top_builddir)/src/ $(GLIB_CFLAGS) $(GTHREAD_CFLAGS)
-LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) $(GTHREAD_LIBS)
+LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) $(GTHREAD_LIBS) -lstdc++
 
 EXTRA_DIST += hb-test.h
Comment 9 Behdad Esfahbod 2012-12-19 01:40:16 UTC
I think I fixed this now.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.