在Mac平台构建Xerces通用二进制库的问题及版本可行性咨询
Short answer: Yes, both Xerces 3.1.1 and 3.2.3 can be compiled into universal (fat) binaries supporting x86_64 and arm64 architectures on macOS. The error you're seeing during configure is related to your compiler environment setup, not an inherent limitation of the Xerces versions.
Fixing the "C++ compiler cannot create executables" error
Your initial configure command is missing critical flags to point the compiler to the macOS SDK provided by Xcode 12.3. Here's how to adjust it:
First, ensure Xcode Command Line Tools are properly installed
Run this in Terminal to confirm or install them:xcode-select --installIf you already have them installed, verify the SDK path is accessible:
xcrun --show-sdk-pathThis should output a path like
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk(matching your Xcode 12.3's SDK version).Use an updated configure command with SDK and explicit compilers
Xcode'sg++is actually an alias for Clang, so explicitly specifyingclang++helps avoid confusion. Add the SDK path to your flags to ensure the compiler can find all necessary headers and libraries:./configure CC=clang CXX=clang++ \ CFLAGS="-arch x86_64 -arch arm64 -isysroot $(xcrun --show-sdk-path)" \ CXXFLAGS="-arch x86_64 -arch arm64 -isysroot $(xcrun --show-sdk-path)" \ LDFLAGS="-arch x86_64 -arch arm64 -isysroot $(xcrun --show-sdk-path)"Troubleshoot with config.log
If you still hit errors, open the generatedconfig.logfile. Look for lines starting withconfigure:3456: g++ -o conftest ...to see the exact compiler error—common issues include missing SDK access permissions or outdated system compiler paths.
Verifying the universal binary
After a successful configure and make (followed by make install if needed), verify the resulting library contains both architectures:
lipo -info /usr/local/lib/libxerces-c.dylib
You should see output like:
Architectures in the fat file: /usr/local/lib/libxerces-c.dylib are: x86_64 arm64
Notes for older Xerces 3.1.1
While 3.1.1 is older, it still works with the above steps. You might encounter minor compiler warnings; if these cause failures, add -Wno-error to your CXXFLAGS to treat warnings as non-fatal:
CXXFLAGS="-arch x86_64 -arch arm64 -isysroot $(xcrun --show-sdk-path) -Wno-error"
内容的提问来源于stack exchange,提问作者Chubsdad

