Cross compile gnupg for Windows on Ubuntu

Cuz I use GPG a lot on Win10 to prevent cloud storage service provider analysis my files, the super slow encryption speed bugs me a lot. I tried to use it on an Ubuntu inside a VM, it is fast, but I have to move the file around, cumbersome.

On my i5-6200u @ 2.40Ghz (AES-NI disabled by Lenovo BIOS), SDD, 16G ram, gpg4win only achieves around 15mB/s. I suspect being a GNU software, some users might still using Pentium 3, hence gpg4win might be compiled without any CPU specified optimization flag, so I need to recompile it myself with some flags.

Without further ado, let’s get started. I just assume people go this deep have a sense of things going well or not, so I won’t give examples of correct output. Please utilize google first when you met errors.

First we need tools

Then get source code for each following step from gnupg.org and zlib.net

Before building GnuPG, we have to had Libgpg-error, Libgcrypt, Libksba, Libassuan, ntbTLS, and nPth ready.

I work on the home folder. Make a build folder:

To get Libgpg-error:

Libgcrypt:

Btw, I use “make -j4” because mine has 4 threads.

Libksba:

Libassuan:

ntbTLS:

Somehow when I compiled nPth, it complains it cannot find zlib.h, so I also compile zlib, it might not be necessary.

zlib:

as stated in here, the configure of zlib is broken by the time I wrote this post, so we need to manually compile zlib:

nPth: (I don’t even know is -lws2_32 necessary or not, it was added after I met some problem when compiling the main gnupg, so I just leave it here)

Finally, gnupg

Linker kept throwing errors when I have all the default stuff enabled, since all I want is the gpg.exe, I disabled many components. Then it works.

the gpg.exe can be found by:

The performance gain is significant, encrypt speed jump to around 60mB/s from 15mB/s. And the file remains the same after encrypt and decrypt. Good deal.

Ref:

https://gist.github.com/ePirat/0fd2c714dea2748cca98cf2096faa574

https://ubuntuforums.org/showthread.php?t=649466

Compiling LAPACK program with g++ in Ubuntu

First thing first, install lapack, lapacke(C wrapper for lapack), and blas.

Let’s use the demo code from http://www.netlib.org/lapack/lapacke.html, save it as test.cpp

That’s all I need to let it compile.

To run it, you just need to

Done. Thanks. Period.