Rexdf

The devil is in the Details.

编译Gpg4win

| Comments

本来在Windows上面我是不需要这样的软件的,一方面我收到的加密邮件并不多,另一方面我已经习惯了用纯命令的方式进行加解密了。来编译这个Gpg4Win 这个页面上我目前最新下载的是gpg4win-2.2.2.exe,但是他们似乎没有严格测试过软件。我从2.2.1升级到2.2.2后,那个GPA密钥管理助手就不能启动,说是缺少libwinpthread-1.dll。更正下,是找不到rand_s,在msvcrt.dll中。

虽然官方使用的是Debian7,我也有装好的Debian系统。不过我选择的我最喜爱的Archlinux来编译的,好处是所有软件足够新,比Ubuntu更加激进,但是又不是Debian系列开发版那种会使人心理不安的那种。其次我在Ubuntu上测试编译了一下,果真不行,Ubuntu上面编译latex的地方就会出错直接终止进程,而我看了下texinfo版本(apt-cache -s texinfo)也是5.2版本的。所以可以肯定,Ubuntu要正常编译出来,要解决的问题一定比Archlinux多得多。(粗略感觉下,我对编译Compendium.pdf这个地方,Latex出错就无能为力了。而且我是完全按照官网指令安装了全部依赖了的。

总之,虽然我物理机装的是Ubuntu,但是对于一些GNU的cpp开发,Ubuntu应该不是一个好的选择。

1.环境介绍

而Archlinux却有好几个包根本找不到任何对应的包,比如latex-xcolor这个,我完全不知道对应什么。不过还好Archlinux有yaourt可以方便安装非官方的包,比如docbook-utils,mingw-w64-**依赖库等。

我的Arch的mingw-w64-gcc是4.9.1-3的,这应该是最前沿的了吧,所有依赖库是非官方维护,通过源码本地编译出来的,所以mingw不会出现找不到符号的错误。这个非常关键。

总之我不知道官方的版本在Debian是否真的如官网编译wiki上面说的那么轻松三条命令搞定

官网编译命令MyBlog
cd gpg4win/packages && ./download.sh && cd ..
./autogen.sh --force
./autogen.sh --build-w32 && make

我没有在Debian上面测试,这看上去把所有的细节都封装到了autogen脚本里面去了。刚刚出错的时候我还不知怎么回事,不过进到目录里面就清楚了。

下面我列出官网顺序执行下的错误列表

2.错误列表:

下面的错误列表我按出现的时间顺序给出。

错误1

  • libadns-1.dll.def:2: syntax error

具体错误信息如下

libadns-1.dll.def:2: syntax error错误信息MyBlog
/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld:.libs/libadns-1.dll.def:2: syntax error
collect2: error: ld returned 1 exit status
Makefile:390: recipe for target 'libadns.la' failed
make[6]: *** [libadns.la] Error 1
make[6]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/adns-1.4-g10-4-build/src'
Makefile:308: recipe for target 'all' failed
make[5]: *** [all] Error 2
make[5]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/adns-1.4-g10-4-build/src'
Makefile:284: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/adns-1.4-g10-4-build'
gpg4win.mk:476: recipe for target 'stamps/stamp-adns-03-make' failed
make[3]: *** [stamps/stamp-adns-03-make] Error 2
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

解决办法:

网上搜索找到了两个

一个邮件里面的patch可以参考,需要手工打patch,因为行号似乎和现在版本对不上。

还是一个邮件,是Fedora上的,不过没有后续提出的解决办法。

我的解决办法,①我尝试过降级libtool,但是libtool是binutils的一部分,降级binutils需要降级gcc,这个就非常麻烦了。简单点说就是不可能的了。

Debian是libtool2.2,好像从libtool2.3就开始不支持def导出符号表中有双行EXPORTS,这个在上面第一个邮件里面争论过,最终是大家都说是upstream的问题或者libtool的错误,反正本该这样支持双EXPORTS等,反正现在是悬着的问题,自然就是留给了我们编译用户了。

②降级binutils不行,自然就是改代码了。准确地说是hacking代码,反正只要欺骗libtool这是一个合格的def导出符号表就行了。对于这个编译过程中工具链的调用方式的真的是没有搞懂的,反正传统的./configure && make是绝对不会编译出正确的结果的,因为是cross-build,自然是要传CXX或者host,target等参数进去的。不过最终我也没有搞懂这些参数是怎么传递进去的,不过问题还是被我给解决了。hacking code

修改的文件MyBlog
vim /home/rexdf/prog/gpg4win/src/playground/build/adns-1.4-g10-4-build/libtool

查找EXPORTS,一直找到echo EXPORTS的一行,我的是325行。

要修改的行MyBlog
echo EXPORTS > \$output_objdir/\$soname.def;
cat \$export_symbols >> \$output_objdir/\$soname.def;

把这两行的第一行删除,第二行的>>改成>,已覆盖而不是追加。

保存退出,继续执行make。vim界面如下如:

结果图

错误2

  • libw32pth-0.dll.def:2: syntax error

具体错误信息如下

libw32pth-0.dll.def:2: syntax error错误信息MyBlog
/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld:.libs/libw32pth-0.dll.def: file format not recognized; treating as linker script
/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld:.libs/libw32pth-0.dll.def:2: syntax error
collect2: error: ld returned 1 exit status
Makefile:421: recipe for target 'libw32pth.la' failed
make[5]: *** [libw32pth.la] Error 1
make[5]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/w32pth-2.0.5-build'
Makefile:331: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/w32pth-2.0.5-build'
gpg4win.mk:476: recipe for target 'stamps/stamp-w32pth-03-make' failed
make[3]: *** [stamps/stamp-w32pth-03-make] Error 2
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

解决办法同 错误1 只要按照上面的修改/home/rexdf/prog/gpg4win/src/playground/build/w32pth-2.0.5-build/libtool即可。然后再次执行make.

错误3

  • libksba-8.dll.def:2: syntax error

解决办法同 错误1 只要按照上面的修改/home/rexdf/prog/gpg4win/src/playground/build/libksba-1.3.0-build/libtool即可。然后再次执行make.

错误4

  • libscute-0.dll.def:2: syntax error

解决办法同 错误1 只要按照上面的修改/home/rexdf/prog/gpg4win/src/playground/build/scute-1.4.0-build/libtool即可。然后再次执行make.

错误5

  • doc/gnutls.info failed

具体错误信息如下:

gnutls的doc编译错误MyBlog
../../gnutls-2.12.23/doc/gnutls.texi:119: warning: node prev `Function and Data Index' in menu `Concept Index' and in sectioning `Bibliography' differ
../../gnutls-2.12.23/doc/gnutls.texi:124: warning: node `Function and Data Index' is next for `Concept Index' in menu but not in sectioning
../../gnutls-2.12.23/doc/gnutls.texi:124: warning: node prev `Concept Index' in menu `Copying Information' and in sectioning `Function and Data Index' differ
Makefile:1377: recipe for target '../../gnutls-2.12.23/doc/gnutls.info' failed
make[8]: *** [../../gnutls-2.12.23/doc/gnutls.info] Error 1
make[8]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gnutls-2.12.23-build/doc'
Makefile:1568: recipe for target 'all-recursive' failed
make[7]: *** [all-recursive] Error 1
make[7]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gnutls-2.12.23-build/doc'
Makefile:1290: recipe for target 'all' failed
make[6]: *** [all] Error 2
make[6]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gnutls-2.12.23-build/doc'
Makefile:1222: recipe for target 'all-recursive' failed
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gnutls-2.12.23-build'
Makefile:1151: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gnutls-2.12.23-build'
gpg4win.mk:476: recipe for target 'stamps/stamp-gnutls-03-make' failed
make[3]: *** [stamps/stamp-gnutls-03-make] Error 2
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

这个错误和前面的错误不同了,这个是兼容问题了gnutls的texi兼容texinfo的4.x版本,而Archlinx版本是5.2-2(甚至Ubuntu都是5.2)。

不过幸运的是Archlinux降级比较方便,而且texinfo似乎没有被任何包依赖。执行如下命令降级。 从这个页面选择一个mirror下载。

降级texinfo命令MyBlog
wget ftp://debian.linux.org.tw/pub/CLE/pub/ArchLinux/current/os/x86_64/texinfo-4.13a-4-x86_64.pkg.tar.xz
sudo pacman -U texinfo-4.13a-4-x86_64.pkg.tar.xz

提示信息如下

降级texinfo提示信息MyBlog
正在加载软件包...
警告:正在降级软件包 texinfo (5.2-2 => 4.13a-4)
正在解决依赖关系...
正在查找相互冲突...
软件包 (1): texinfo-4.13a-4
全部安装大小: 2.34 MiB
净更新大小: -5.47 MiB
:: 进行安装吗? [Y/n] y
(1/1) 正在检查密钥环里的密钥 [##############################################] 100%
(1/1) 正在检查软件包完整性 [##############################################] 100%
(1/1) 正在加载软件包文件 [##############################################] 100%
(1/1) 正在检查文件冲突 [##############################################] 100%
(1/1) 正在检查可用硬盘空间 [##############################################] 100%
(1/1) 降级中 texinfo

然后再次执行make.

错误6

  • 无法获取”gtk-tut” 的文件状态(stat): 没有那个文件或目录

提示信息如下

gtk-2.24编译错误信息MyBlog
window);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return 0;
}Done.
mv: 无法获取"gtk-tut" 的文件状态(stat): 没有那个文件或目录
mkdir: 无法创建目录"html/images": 没有那个文件或目录
cp: 目标"html/images" 不是目录
Makefile:645: recipe for target 'html' failed
make[7]: *** [html] Error 1
make[7]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gtk+-2.24.24-build/docs/tutorial'
Makefile:493: recipe for target 'all-recursive' failed
make[6]: *** [all-recursive] Error 1
make[6]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gtk+-2.24.24-build/docs'
Makefile:719: recipe for target 'all-recursive' failed
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gtk+-2.24.24-build'
Makefile:610: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/rexdf/prog/gpg4win/src/playground/build/gtk+-2.24.24-build'
gpg4win.mk:476: recipe for target 'stamps/stamp-gtk+-03-make' failed
make[3]: *** [stamps/stamp-gtk+-03-make] Error 2
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

这个是在编译gtk2.24的html版本doc的时候出错了。

在这封邮件里面提到了同样的问题。

因为我们是在编译gpg4win,而不是gtk,所以doc完全可以忽略的。因此我采用了比较粗暴的hacking。

修改gtk的doc问题MyBlog
vim /home/rexdf/prog/gpg4win/src/playground/build/gtk+-2.24.24-build/docs/Makefile

查找tutorial,找到SUBDIRS = tutorial faq reference tools一行,直接删除tutorial和faq两项。我的在444行。

结果如下图

结果图

然后再次执行make.

错误7

  • 找不到libgcc_s_sjlj-1.dll-x和libstdc++-6.dll-x

具体错误信息如下

找不到libstdc++-6.dll-xMyBlog
- g4wihelp::stopsound
File: "/home/rexdf/prog/gpg4win/src/libstdc++-6.dll-x" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
!include: error in script: "inst-gpg4win.nsi" on line 93
!include: error in script: "inst-sections.nsi" on line 22
Error in script "./gpg4win.nsi" on line 223 -- aborting creation process
Makefile:1461: recipe for target 'gpg4win-2.2.2-beta3.exe' failed
make[3]: *** [gpg4win-2.2.2-beta3.exe] Error 1
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

解决命令

拷贝两个缺失的dll-xMyBlog
cp /usr/i686-w64-mingw32/bin/libgcc_s_sjlj-1.dll src/libgcc_s_sjlj-1.dll-x
cp /usr/i686-w64-mingw32/bin/libstdc++-6.dll src/libstdc++-6.dll-x

错误8

  • 找不到pinentry-w32.exe和pinentry-qt4.exe

具体错误信息如下

找不到pinentry-w32.exeMyBlog
- g4wihelp::stopsound
File: "playground/install/pkgs/pinentry-0.8.4-beta8/bin/pinentry-w32.exe" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
!include: error in script: "inst-pinentry.nsi" on line 38
!include: error in script: "inst-sections.nsi" on line 141
Error in script "./gpg4win.nsi" on line 223 -- aborting creation process
Makefile:1461: recipe for target 'gpg4win-2.2.2-beta3.exe' failed
make[3]: *** [gpg4win-2.2.2-beta3.exe] Error 1
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

解决命令

拷贝两个缺失的pinentry-*.exeMyBlog
cp src/playground/build/pinentry-0.8.4-beta8-build/w32/pinentry-w32.exe src/playground/install/pkgs/pinentry-0.8.4-beta8/bin/pinentry-w32.exe
cp src/playground/build/pinentry-0.8.4-beta8-build/qt4/pinentry-qt4.exe src/playground/install/pkgs/pinentry-0.8.4-beta8/bin/pinentry-qt4.exe

然后执行make.

错误9

  • 找不到gpgex.dll

具体错误信息如下

找不到gpgex.dllMyBlog
File: "playground/install-ex/pkgs/gpgex-1.0.1/bin/gpgex.dll" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
!include: error in script: "inst-gpgex.nsi" on line 87
!include: error in script: "inst-sections.nsi" on line 162
Error in script "./gpg4win.nsi" on line 223 -- aborting creation process
Makefile:1461: recipe for target 'gpg4win-2.2.2-beta3.exe' failed
make[3]: *** [gpg4win-2.2.2-beta3.exe] Error 1
make[3]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:963: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rexdf/prog/gpg4win/src'
Makefile:722: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rexdf/prog/gpg4win'
Makefile:660: recipe for target 'all' failed
make: *** [all] Error 2

解决般办法

拷贝gpgex.dllMyBlog
mkdir -p src/playground/install-ex/pkgs/gpgex-1.0.1/bin/
cp src/playground/build/gpgex-1.0.1-build/src/gpgex.dll src/playground/install-ex/pkgs/gpgex-1.0.1/bin/gpgex.dll

然后执行make. 结果如下如。 结果图

补充错误

  • 缺少stow等configure的fail。

对于configure阶段的error我都是没有列出来的因为不记得了。大体的解决思路是缺少什么首先pacman -S然后yaourt -S,如果找不到则到网上搜索对应于Archlinux的包名称。因为Redhat系列、Debian系列与Archlinux系列一些包,特别是dev和header后缀的一些包,在Archlinux中都是不存在的,只要安装对应的主包即可。

收尾工作

在Archlinux中执行sudo pacman -Syu把texinfo升级回去。缺少libwinpthread-1.dll在/usr/i686-w64-mingw32/bin/下面,scp复制出来,放到Gpg4win的Windows安装目录就好了,注意时机,越早越好,否则会有一些组件注册失败。

结果

结果图 结果图 结果图 结果图 结果图 结果图

不知道怎么回事虽然configure的时候是选的w32,但是Claws-Mail还是被编译成64位的了,在32位XP下面无法打开Claws-Mail。

结果图

结果图

Comments