Mac Catalina编译Emacs 27踩坑

Catalina没了自动装header file的那个安装包,/usr/include也变成只读,直接编译Emacs就会找不到头文件:

emacs/ 吉 > make
...
xml.c:26:10: fatal error: 'libxml/tree.h' file not found
...

解决方法是configure的时候加上include地址:

emacs/ 吉 > gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

这个--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/就是头文件地址了,找一找libxml,发现在libxml2里。

所以configure这么写:

./configure --with-modules --with-pdumper=yes --oldincludedir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/

然后make。


P.S. 大概是我启用了portable dumper,make的时候又有个报错:

Loading /Users/yuan/attic/emacs/lisp/loaddefs.el (source)...
Symbol’s value as variable is void: ctl-x-6-map
make[1]: *** [bootstrap-emacs.pdmp] Error 255
make: *** [src] Error 2

emacs-devel里有个回复说用make bootstrap可以解决。我make bootstrap又出个问题,大概长这样:

emacs: could not load dump file
 "/Applications/Emacs.app/Contents/MacOS/Emacs.pdmp": not built for
 this Emacs executable

我没管,又make一遍,就没问题了……

1 个赞

Catalina 太不稳定了,我升级后窗口频繁切换焦点,根本没法用,只好重装mojave。建议没有升级的伙伴谨慎升级

如果你从 homebrew 安装 pkg-config 的话,可以用这个 patch:pkgconfig_10.15.diff · GitHub

麻烦之处是每次 patch 好,编译完之后最好 revert 掉,否则下次 brew update 的时候会覆盖。

另外这个头文件的改动从上一个版本 Mojave 就有了。

homebrew 相关的讨论这里可以找到,目前看没什么特别好的方法

之前用安装包装一下就不用管了,现在没了。

这个很棒!我对编译打包这些不怎么懂,每次出问题总要折腾半天。


BTW,听说macport不用mac自带的library,会不会没有这些问题?