macOS LibreOffice 编译错误解决#

错误1#

checking for bogus pkg-config... configure: error: yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that pkgconf-2.5.1/pkgconf is no longer found by configure scripts.

排查思路:

  1. 怀疑是自编译未make install pkg-config环境变量配置问题,但是执行pkg-config --version命令,返回0.29.2,说明pkg-config环境变量配置正确。

  2. 检查环境变量PKG_CONFIG_PATH也没有问题,执行pkgconf --libs openssl返回 -L/opt/homebrew/Cellar/openssl@3/3.5.0/lib -lssl -lcrypto,说明pkg-config环境变量配置正确。

  3. 检查configure文件,发现如下内容

vi configure
--enable-bogus-pkg-config
           MACOSX only: on MacOSX pkg-config can cause trouble.
           by default if one is found in the PATH, an error is
           issued. This flag turn that error into a warning.

解决方法

vi autogen.lastrun
追加
--enable-bogus-pkg-config

错误2#

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-macos -stdlib=libc++ -mmacosx-version-min=11.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk -Isrc/libharfbuzz.a.p -Isrc -I../src -I. -I.. -I/Users/Libreoffice/core/workdir/UnpackedTarball/graphite/include -I/Users/Libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I/Users/Libreoffice/core/workdir/UnpackedTarball/icu/source/common -fvisibility=hidden -fdiagnostics-color=always -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wall -Winvalid-pch -std=c++20 -fno-exceptions -O3 -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -DHAVE_CONFIG_H -DGRAPHITE2_STATIC -MD -MQ src/libharfbuzz.a.p/hb-buffer-serialize.cc.o -MF src/libharfbuzz.a.p/hb-buffer-serialize.cc.o.d -o src/libharfbuzz.a.p/hb-buffer-serialize.cc.o -c ../src/hb-buffer-serialize.cc
In file included from ../src/hb-buffer-serialize.cc:27:
In file included from ../src/hb.hh:199:
In file included from ../src/hb.h:31:
In file included from ../src/hb-blob.h:34:
In file included from ../src/hb-common.h:66:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/usr/include/c++/v1/inttypes.h:241:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/usr/include/c++/v1/__config:49:6: error: "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"
   49 | #    error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"
      |      ^
1 error generated.

解决思路: 错误信息:_LIBCPP_ENABLE_ASSERTIONS已弃用,请使用_LIBCPP_HARDENING_MODE代替。全文搜索_LIBCPP_ENABLE_ASSERTIONS找到使用_LIBCPP_ENABLE_ASSERTIONS=1的地方替换为_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG

解决方法:

vi Libreoffice/core/workdir/UnpackedTarball/harfbuzz/builddir/build.ninja
找到
-D_LIBCPP_ENABLE_ASSERTIONS=1
替换为
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG