I downloaded an open source Qt project which uses Botan library. Specifically, the project includes Botan header files in its source files such as:
And the project links with Botan’s binary library. At first, I want to download a pre-built Botan dll and library to use. Unfortunately, I can not find a pre-compiled Botan binary on the Internet. It seems I have to build the library from Botan source code. I have no idea of this library at all. It is even hard to find Botan’s official site. Searching google for botan gives me some ambiguous urls. They are not botan.com or botan.org, or something like that. It took me some time to make sure botan.randombit.net is Botan’s official site. The site is full of documents and strange articles which hide the download link. Finally, I got the Botan download url:https://botan.randombit.net/releases/Botan-2.1.0.tgz. The problem now is how to build it under Windows using Mingw.
According to its manual, you should have python installed to build Botan. This is a common headache for Windows developers to build those Linux projects. They need to install a bunch of tools (the Windows versions of their Linux counterparts) to build a little project. Fortunately, I have already installed a Windows version of Python(I even forget when I installed this tool and where I downloaded it.) Anyway, I unzip the downloaded Botan package and cd to that directory and issue the following command:
python configure.py –cc=gcc
Not surprisingly, things would not go smooth when building a Linux project under Windows. Now after some time, the following error ocured:
process_begin: CreateProcess(NULL, rm -f ./botan.lib, …) failed.
I wonder why it calls the linux rm command? Well, the Mingw accompanied by Qt does not have that command. Fortunately, I installed a full MingW which has a sub-directory called msys. msys simulates basic linux commands including rm. I added the msys/bin to the environment variable PATH and error disappeared. Now comes the next error:
../i686-w64-mingw32/bin/ld.exe: cannot find -ladvapi32.lib
../i686-w64-mingw32/bin/ld.exe: cannot find -luser32.lib
Interesting! Botan wants to include Windows into its library. Edit the Makefile changing
LIB_LINKS_TO = -ladvapi32.lib -luser32.lib
Now the error is:
ln: `botan.dll’ and `./botan.dll’ are the same file
You can now ignore that error because botan.lib and botan.dll have been generated in the top directory of the Botan folder.
To me the building is accomplished. I got the .lib file, the .dll file ,and the include files in the build folder. But the include files are a little strange to me. build/include has two sub-folders: botan and external. build/include/botan has another sub-folder: internal. Are all those sub-folders and include files in those sub-folders necessary? It is better to run “mingw32-make install” to see what on earth will be installed on the system. But by default the files will be installed in c:\Botan, which is not what I want. I changed the –destdir=c:\Botan to a appropriate directory (d:\dev\Botan) in the Makefile and executed the install. Now the error is:
cp doc\manual\*.rst build\docs\manual
cp: cannot stat `docmanual*.rst': No such file or directory
Ok, I do not want the documents. Delete the doc dependency of the install target and re-run the ming232-make install:
/usr/bin/sh: srcscripts/install.py: No such file or directory
Change SCRIPTS_DIR = src\scripts to SCRIPTS_DIR = src/scripts
Now the error:
ERROR: Failure: [Errno 2] No such file or directory: u’.\\botan-cli.exe’
Rename botan.exe in top directory to botan-cli.exe:
Now no error any more, but there are no files installed in the specified directory(d:\dev\Botan), even no Botan directory in D:\dev\. Instead a folder d:\devBotan was created and everything was installed in that directory. Only after I changed –destdir to –destdir=d:/dev/Botan did the installation script install the files to the correct folder. A very silly script, isn’t it?