From b33a6f3098e3d8f7a26fc082976d7c52deead709 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh <aquynh@gmail.com> Date: Tue, 11 Oct 2016 00:34:49 +0800 Subject: [PATCH] docs: cleanup COMPILE-WINDOWS-CROSS.md --- docs/COMPILE-WINDOWS-CROSS.md | 60 +++++++++++++++++++++++++++++++ docs/COMPILE.md | 2 ++ docs/CROSS-COMPILATION-AS-LIB.md | 61 -------------------------------- 3 files changed, 62 insertions(+), 61 deletions(-) create mode 100644 docs/COMPILE-WINDOWS-CROSS.md delete mode 100644 docs/CROSS-COMPILATION-AS-LIB.md diff --git a/docs/COMPILE-WINDOWS-CROSS.md b/docs/COMPILE-WINDOWS-CROSS.md new file mode 100644 index 0000000..0678f7e --- /dev/null +++ b/docs/COMPILE-WINDOWS-CROSS.md @@ -0,0 +1,60 @@ +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 diff --git a/docs/COMPILE.md b/docs/COMPILE.md index 1135cc5..ad19d3f 100644 --- a/docs/COMPILE.md +++ b/docs/COMPILE.md @@ -3,6 +3,8 @@ see [COMPILE-NIX.md](COMPILE-NIX.md) To compile Keystone on Windows, see [COMPILE-WINDOWS.md](COMPILE-WINDOWS.md) +To cross-compiling for Windows from Linux, see [COMPILE-WINDOWS-CROSS.md](COMPILE-WINDOWS-CROSS.md) + Learn more on how to code your own tools with our samples. - For C sample code, see code in directory samples/ diff --git a/docs/CROSS-COMPILATION-AS-LIB.md b/docs/CROSS-COMPILATION-AS-LIB.md deleted file mode 100644 index 995b6e3..0000000 --- a/docs/CROSS-COMPILATION-AS-LIB.md +++ /dev/null @@ -1,61 +0,0 @@ -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