4

I'm trying to link xerces as a static library, but I have some problems...

Undefined symbols for architecture x86_64:
  "_CFRelease", referenced from:
      xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
      xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
  "_CFStringCreateMutableWithExternalCharactersNoCopy", referenced from:
      xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
      xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
  "_CFStringLowercase", referenced from:
      xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
  "_CFStringUppercase", referenced from:
      xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
  "_CreateTextEncoding", referenced from:
      xercesc_3_1::MacOSUnicodeConverter::discoverLCPEncoding() in libxerces-c.a(MacOSUnicodeConverter.o)
      xercesc_3_1::MacOSUnicodeConverter::makeNewXMLTranscoder(unsigned short const*, xercesc_3_1::XMLTransService::Codes&, unsigned long, unsigned int, xercesc_3_1::MemoryManager*) in libxerces-c.a(MacOSUnicodeConverter.o)
   ...

I've tried to run configure with different options, but all attempts were useless.

Has anyone had the same problem?

  • Maybe it's caused by this: https://xerces.apache.org/xerces-c/build-3.html _If you are linking your application to the static Xerces-C++ library, then you will need to compile your application with the XERCES_STATIC_LIBRARY preprocessor macro defined in order to turn off the DLL import/export mechanism._ – Erik Sjölund Feb 02 '16 at 17:55

1 Answers1

4

I ran into this issue when building xalan. I fixed it by passing -framework CoreServices -framework CoreFoundation -lcurl to the linker.

Line 76 of xalan's Makefile.incl:

XERCES_LIB = -L$(XERCESCROOT)/lib -lxerces-c -framework CoreServices -framework CoreFoundation -lcurl
Bruno Jouhier
  • 1,013
  • 9
  • 11
  • Thank you. This saved me so much troubleshooting. For me it was sufficient to add `-framework CoreServices -lcurl`. How did you find out this was the issue? The documentation at [clang's website](https://clang.llvm.org/docs/ClangCommandLineReference.html) is not very clear on what `-framework` does. – segfault Nov 24 '20 at 05:08
  • Saved me a lot of trouble too. Note I didn't need -framework CoreFoundation when building xerces on my MacBook pro – Bathsheba Mar 31 '23 at 10:38