6e4dfbec |
1 | Building with CMake for Android {#occt_dev_guides__building_android} |
9f33b387 |
2 | =================== |
3 | |
4 | @tableofcontents |
5 | |
6e4dfbec |
6 | This article describes the steps to build OCCT libraries for Android from a complete source package |
7 | with GNU make (makefiles) on Windows 7 and Ubuntu 15.10. |
8 | |
9 | The steps on Windows and Ubuntu are similar. There is the only one difference: makefiles are built with mingw32-make |
10 | on Windows and native GNU make on Ubuntu. |
11 | |
12 | Required tools (download and install if it is required): |
13 | - CMake v3.0+ http://www.cmake.org/cmake/resources/software.html |
14 | - Cross-compilation toolchain for CMake https://github.com/taka-no-me/android-cmake |
15 | - Android NDK rev.10+ https://developer.android.com/tools/sdk/ndk/index.html |
16 | - GNU Make: MinGW v4.82+ for Windows (http://sourceforge.net/projects/mingw/files/), GNU Make 4.0 for Ubuntu. |
17 | |
18 | ## Generation of makefiles |
9f33b387 |
19 | Run GUI tool provided by CMake: cmake-gui |
20 | |
21 | ### Tools configuration |
beb18c1f |
22 | - Specify the root folder of OCCT (<i>$CASROOT</i>, which contains *CMakelists.txt* file) by clicking **Browse Source**. |
9f33b387 |
23 | - Specify the location (build folder) for Cmake generated project files by clicking **Browse Build**. |
24 | |
25 | @figure{/dev_guides/building/android/images/android_image001.png} |
26 | |
6e4dfbec |
27 | Click **Configure** button. It opens the window with a drop-down list of generators supported by CMake project. |
9f33b387 |
28 | |
6e4dfbec |
29 | Select "MinGW MakeFiles" item from the list |
9f33b387 |
30 | - Choose "Specify toolchain file for cross-compiling" |
31 | - Click "Next" |
32 | @figure{/dev_guides/building/android/images/android_image002.png} |
6e4dfbec |
33 | |
34 | - Specify a toolchain file at the next dialog by android.toolchain.cmake . It is contained by cross-compilation toolchain for CMake |
9f33b387 |
35 | - Click "Finish" |
36 | @figure{/dev_guides/building/android/images/android_image003.png} |
37 | |
6e4dfbec |
38 | If ANDROID_NDK environment variable is not defined in current OS, add cache entry ANDROID_NDK (entry type is PATH) - path to the NDK folder ("Add Entry" button) |
9f33b387 |
39 | @figure{/dev_guides/building/android/images/android_image004.png} |
40 | |
6e4dfbec |
41 | If on Windows the message is appeared: "CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles" |
42 | CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.", |
43 | specify **CMAKE_MAKE_PROGRAM** to mingw32-make executable. |
9f33b387 |
44 | @figure{/dev_guides/building/android/images/android_image005.png} |
45 | |
46 | ### OCCT Configuration |
47 | |
48 | How to configure OCCT, see "OCCT Configuration" section of @ref occt_dev_guides__building_cmake "Building with CMake" |
49 | taking into account the specific configuration variables for android: |
50 | - ANDROID_ABI = armeabi-v7a |
51 | - ANDROID_NATIVE_API_LEVEL = 15 |
6e4dfbec |
52 | - ANDROID_NDK_LAYOUT is equal to CMAKE_BUILD_TYPE variable |
53 | - **BUILD_MODULE_Draw = OFF** |
9f33b387 |
54 | |
55 | @figure{/dev_guides/building/android/images/android_image006.png} |
56 | |
6e4dfbec |
57 | ### Generation of makefiles |
9f33b387 |
58 | |
59 | Click **Generate** button and wait until the generation process is finished. |
6e4dfbec |
60 | Then makefiles will appear in the build folder (e.g. <i> D:/tmp/occt-android </i>). |
9f33b387 |
61 | |
6e4dfbec |
62 | ## Building makefiles of OCCT |
9f33b387 |
63 | |
6e4dfbec |
64 | Open console and go to the build folder. Type "mingw32-make" (Windows) or "make" (Ubuntu) to start build process. |
65 | |
66 | > mingw32-make |
67 | or |
68 | > make |
69 | |
70 | |
71 | Parallel building can be started with using **"-jN"** argument of "mingw32-make/make", where N is the number of building threads. |
72 | |
73 | > mingw32-make -j4 |
74 | or |
75 | > make -j4 |
76 | |
77 | ## Install built OCCT libraries |
78 | |
79 | Type "mingw32-make/make" with argument "install" to place the libraries |
80 | to the install folder (see "OCCT Configuration" section of @ref occt_dev_guides__building_cmake "Building with CMake") |
81 | |
82 | > mingw32-make install |
83 | or |
84 | > make install |