mac源码编译git问题解决
缘起
由于使用过有半年的ubuntu系统,同时是命令行深度用户,对命令行非常钟爱,换了mac后也是一直使用命令行git进行代码的管理操作。在大约一年前吧,将深度使用的gitk工具增加了中文翻译,提交了patch(额这个gitk项目两年没更新了,提交的patch杳无音信),之后就一直使用自行编译的git已经gitk。
在今年前半年的使用,还可以正常的拉代码编译,半年更新了系统后,就再也不能编译通过了,现在终于有时间折腾下这个问题,所以有了上周的折腾以及这篇文章。
折腾过程
之前写了个脚本,直接使用下面的命令行,一气呵成的拉代码&编译&安装
export XML_CATALOG_FILES=/usr/local/etc/xml/catalog && proxy git pull && make clean && make configure && ./configure && make -j96 all doc && sudo make install install-doc install-html
出现问题后呢,就一直出现下面的错误:
ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clangclang: error: linker command failed with exit code 1 (use -v to see invocation) : error: linker command failed with exit code 1 (use -v to see invocation) clang: error: linker command failed with exit code 1 (use -v to see invocation) clangmake: *** [Makefile:2369: git-shell] Error 1 make: *** Waiting for unfinished jobs.... make: *** [Makefile:2369: git-sh-i18n--envsubst] Error 1 : error: linker command failed with exit code 1 (use -v to see invocation) clang: make: *** [Makefile:2369: git-credential-cache--daemon] Error 1 error: linker command failed with exit code 1 (use -v to see invocation) clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2369: git-credential-cache] Error 1 make: *** [Makefile:2369: git-credential-store] Error 1 make: *** [Makefile:2383: git-remote-testsvn] Error 1 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2393: git-remote-http] Error 1 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2369: git-http-backend] Error 1 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2372: git-imap-send] Error 1 make: *** [Makefile:2379: git-http-push] Error 1 clang: error: linker command failed with exit code 1 (use -v to see invocation) clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2376: git-http-fetch] Error 1 make: *** [Makefile:2369: git-daemon] Error 1 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2369: git-fast-import] Error 1 ld: archive has no table of contents file 'xdiff/lib.a' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:2046: git] Error 1
其中核心的问题是ld链接时的command 32 not found问题,搜遍了全网,也没有找到靠谱的解决方案(包括在git的maillist里提问),最终在brew的仓库中看到类似的问题,可能是由于在mac 10.14中,之前随command line tool sdk安装的unix系统header现在不默认安装了,需要手工安装。
于是从https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_macOS_10.14_for_Xcode_10.1/Command_Line_Tools_macOS_10.14_for_Xcode_10.1.dmg 下载了适合10.14的command line tool 安装,安装完发现并不能解决问题,于是又各种查资料,发现在这个command line tool内部还有一个header的pkg,于是按如下命令手工安装了header,
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target
终于,git能够正常的编译了。
剩余的问题:
如上步骤已经可以正常编译git了,但是发现并不能自动编译对应locale的语言,而git正式发布的bin中,是有locale对应的翻译的,比如中文环境下,git的帮助是中文的,这个问题还没有找到解决方案,待后续再处理吧。
经过这两天的折腾,终于这个问题也解决了,问题原因是很多的开源软件使用gnu体系内的gettext做国际化的事情,因此在mac上需要安装gettext,同时需要link以下,按照如下命令更新后就可以正常编译出locale对应的语言了。
brew install gettext brew link --force gettext
至此,所有的问题已经解决了,过程很折腾,开源项目还是比较需要耐心以及精力才能玩好的,🐶
总结
开源项目,如果你想玩的很溜,其实是要花费很多的时间处理各种事情的,而且有些细节还有平台差异,这些其实是很坑的。、。。。另一个感受,就是传统的开源项目中,广泛的使用非常原始的maillist去追踪问题,这个是非常不好的,感觉非常难用。。。。
参考
https://stackoverflow.com/questions/14940383/how-to-install-gettext-on-macos-x/33896321#33896321
已有1位网友发表了看法:
发表评论