From f8962e9c7f775215621af033943df3cd4379a645 Mon Sep 17 00:00:00 2001 From: ZILIO Nicolas <nzilio@lexsi.com> Date: Mon, 10 Oct 2016 18:14:03 +0200 Subject: [PATCH] added documentation for using keystone as a library in cross compiled project --- docs/CROSS-COMPILATION-AS-LIB.md | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docs/CROSS-COMPILATION-AS-LIB.md diff --git a/docs/CROSS-COMPILATION-AS-LIB.md b/docs/CROSS-COMPILATION-AS-LIB.md new file mode 100644 index 0000000..995b6e3 --- /dev/null +++ b/docs/CROSS-COMPILATION-AS-LIB.md @@ -0,0 +1,61 @@ +This documentation explains how to use the keystone project as a library in a cross compiled project. It assumes the use of mingw gcc suite for compilation. + + +Cross-compiling for windows from linux + +0. Dependency + + To be able to cross-compile from linux to windows, you will need the windows libraries found on the download page of keystone engine. After download, decompress them and place them in you project path. + + +1. Dynamic Libraries + + To use the dynamic libraries of keystone, just use the following in your gcc command line : + -I ./<path to>/keystone-0.9.1-winXX/include/ for the include part + -L ./<path to>/keystone-0.9.1-winXX/ -lkeystone for the linking part + +where XX is 32 or 64. + +To be able to use you compiled application on windows, ship then the keystone.dll file with your application. + + +2. Static Libraries + + To avoid shipping the dll file with your project, you may want to use the keystone static libraries instead. + + 2.1. 32 bits architecture + + There, you would use the following on your gcc command line : + -I ./<path to>/keystone-0.9.1-win32/include/ for the include part + ./<path to>/keystone-0.9.1-winXX/keystone.lib for the linking part + + + Your mingw compiler should be able to understand the .lib file directly (not tested for now). + + + 2.2. 64 bits architecture + Using the 64 bits version of keystone.lib is not recognized by the mingw compiler. There is so a need in transforming the keystone.lib file into a keystone.a file. + + 2.2.1. Dependency + + gendef and dlltool are required to translate the lib file. + + - On Ubuntu Linux (debian based), install "gendef" with: + + $ sudo apt-get install mingw-w64-tools + + - dlltool is normally shipped with your installation of the mingw compiler (on a 64 bits ubuntu, you will find it as x86_64-w64-mingw32-dlltool). If you don't have it, you can install it : + + $ sudo apt-get install mingw-w64 + + + + 2.2.2. In the keystone-0.9.1-win64 directory, enter the following commands : + $ gendef keystone.dll + $ x86_64-w64-mingw32-dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libkeystone.a --input-def keystone.def + + + 2.2.3. You now have a standard .a file that can be used in you command to compile by using : + -I ./<path to>/keystone-0.9.1-win32/include/ for the include part + ./<path to>/keystone-0.9.1-winXX/keystone.a for the linking part + -- GitLab