ld:bind_at_load和-bitcode_bundle(Xcode设置ENABLE_bitcode=YES)不能

ld: -bind_at_load and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together

本文关键字:bitcode ENABLE 设置 YES 不能 Xcode bundle at bind load ld      更新时间:2023-10-16

我已经设置了以下编译器和链接器设置,用于为我的IOS库构建harfbuzz:

CC=clang 
CXX=clang++ CXXFLAGS='-miphoneos-version-min=9.0 -stdlib=libc++ -pipe -arch arm64 -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include -I./include/  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -Wl,-headerpad_max_install_names  -fembed-bitcode' CFLAGS=' -miphoneos-version-min=9.0 -pipe -arch arm64 -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include -I./include/  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -Wl,-headerpad_max_install_names  -fembed-bitcode' ./configure --with-freetype=no --with-glib=no --with-cairo=no --with-fontconfig=no --enable-static --host=arm-apple-darwin --with-icu=no

之后,我运行make命令,得到以下错误:ld:-bind_at_load和-bitcode_bundle(Xcode设置ENABLE_bitcode=YES(不能一起使用。以下是堆栈跟踪:

manas-534:harfbuzz manasaga$ make
/Users/manasaga/Downloads/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in src
/Users/manasaga/Downloads/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in hb-ucdn
CC       libhb_ucdn_la-ucdn.lo
CCLD     libhb-ucdn.la
CXX      libharfbuzz_la-hb-blob.lo
CXX      libharfbuzz_la-hb-buffer-serialize.lo
CXX      libharfbuzz_la-hb-buffer.lo
CXX      libharfbuzz_la-hb-common.lo
CXX      libharfbuzz_la-hb-face.lo
CXX      libharfbuzz_la-hb-font.lo
CXX      libharfbuzz_la-hb-map.lo
CXX      libharfbuzz_la-hb-ot-tag.lo
CXX      libharfbuzz_la-hb-set.lo
CXX      libharfbuzz_la-hb-shape.lo
CXX      libharfbuzz_la-hb-shape-plan.lo
CXX      libharfbuzz_la-hb-shaper.lo
CXX      libharfbuzz_la-hb-static.lo
CXX      libharfbuzz_la-hb-unicode.lo
CXX      libharfbuzz_la-hb-warning.lo
CXX      libharfbuzz_la-hb-aat-layout.lo
CXX      libharfbuzz_la-hb-ot-face.lo
CXX      libharfbuzz_la-hb-ot-font.lo
CXX      libharfbuzz_la-hb-ot-layout.lo
CXX      libharfbuzz_la-hb-ot-color.lo
CXX      libharfbuzz_la-hb-ot-map.lo
CXX      libharfbuzz_la-hb-ot-math.lo
CXX      libharfbuzz_la-hb-ot-shape.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-arabic.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-default.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-hangul.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-hebrew.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-indic.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-indic-table.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-khmer.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-myanmar.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-thai.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-tibetan.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-use.lo
CXX      libharfbuzz_la-hb-ot-shape-complex-use-table.lo
CXX      libharfbuzz_la-hb-ot-shape-normalize.lo
CXX      libharfbuzz_la-hb-ot-shape-fallback.lo
CXX      libharfbuzz_la-hb-ot-var.lo
CXX      libharfbuzz_la-hb-fallback-shape.lo
CXX      libharfbuzz_la-hb-ucdn.lo
make[5]: Nothing to be done for `all'.
GEN      libharfbuzz.la
CXX      libharfbuzz_subset_la-hb-static.lo
CXX      libharfbuzz_subset_la-hb-subset.lo
CXX      libharfbuzz_subset_la-hb-subset-glyf.lo
CXX      libharfbuzz_subset_la-hb-subset-input.lo
CXX      libharfbuzz_subset_la-hb-subset-plan.lo
CXXLD    libharfbuzz-subset.la
CXX      main-main.o
CXXLD    main
ld: -bind_at_load and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [main] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

编辑:我更新的链接器和编译器设置

CC=clang CXX=clang++ IPHONEOS_DEPLOYMENT_TARGET=9.0 LD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld LDFLAGS='-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk' AS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar LIBTOOL=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool CXXFLAGS='-stdlib=libc++ -pipe -arch arm64 -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/usr/include -I./include/  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -Wl,-headerpad_max_install_names  -fembed-bitcode' CFLAGS='-pipe -arch arm64 -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk/usr/include -I./include/  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -Wl,-headerpad_max_install_names  -fembed-bitcode' ./configure --with-freetype=no --with-glib=no --with-cairo=no --with-fontconfig=no --enable-static --host=arm-apple-darwin -with-cross-build=/Users/manasaga/Perforce/releases/esg/lipika/main/wrservices/External/Harfbuzz/Source/harfbuzz/ios_mac/ --with-icu=no

因为修复了"libtool"中的错误:

if test "$tagname" = CXX ; then
case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10.[0123])
compile_command+=" ${wl}-bind_at_load"
finalize_command+=" ${wl}-bind_at_load"
;;
esac
fi

你可以运行这个:

export MACOSX_DEPLOYMENT_TARGET="10.14.1"

然后取得成功。