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): |
a20cce39 |
13 | - CMake v3.7+ http://www.cmake.org/cmake/resources/software.html |
6e4dfbec |
14 | - Android NDK rev.10+ https://developer.android.com/tools/sdk/ndk/index.html |
15 | - GNU Make: MinGW v4.82+ for Windows (http://sourceforge.net/projects/mingw/files/), GNU Make 4.0 for Ubuntu. |
a20cce39 |
16 | |
17 | ## Prerequisites |
18 | |
19 | In toolchain file <i>$CASROOT/adm/templates/android.toolchain.config.cmake</i>: |
20 | |
21 | - Set CMAKE_ANDROID_NDK variable equal to your Android NDK path. |
22 | - Set CMAKE_ANDROID_STL_TYPE variable to specify which C++ standard library to use. |
23 | |
24 | The default value of CMAKE_ANDROID_STL_TYPE is <i>gnustl_shared</i> (GNU libstdc++ Shared) |
25 | |
26 | @figure{/dev_guides/building/android/images/android_image001.png} |
27 | |
28 | ## Generation of makefiles using CMake GUI tool |
9f33b387 |
29 | Run GUI tool provided by CMake: cmake-gui |
30 | |
31 | ### Tools configuration |
beb18c1f |
32 | - Specify the root folder of OCCT (<i>$CASROOT</i>, which contains *CMakelists.txt* file) by clicking **Browse Source**. |
9f33b387 |
33 | - Specify the location (build folder) for Cmake generated project files by clicking **Browse Build**. |
34 | |
a20cce39 |
35 | @figure{/dev_guides/building/android/images/android_image002.png} |
9f33b387 |
36 | |
6e4dfbec |
37 | Click **Configure** button. It opens the window with a drop-down list of generators supported by CMake project. |
9f33b387 |
38 | |
a20cce39 |
39 | Select "MinGW Makefiles" item from the list |
9f33b387 |
40 | - Choose "Specify toolchain file for cross-compiling" |
41 | - Click "Next" |
6e4dfbec |
42 | |
9f33b387 |
43 | @figure{/dev_guides/building/android/images/android_image003.png} |
44 | |
a20cce39 |
45 | - Specify a toolchain file at the next dialog by <i>android.toolchain.config.cmake</i> . It is contained by cross-compilation toolchain for CMake |
46 | - Click "Finish" |
9f33b387 |
47 | @figure{/dev_guides/building/android/images/android_image004.png} |
48 | |
6e4dfbec |
49 | If on Windows the message is appeared: "CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles" |
50 | CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.", |
51 | specify **CMAKE_MAKE_PROGRAM** to mingw32-make executable. |
9f33b387 |
52 | @figure{/dev_guides/building/android/images/android_image005.png} |
53 | |
54 | ### OCCT Configuration |
55 | |
56 | How to configure OCCT, see "OCCT Configuration" section of @ref occt_dev_guides__building_cmake "Building with CMake" |
9f33b387 |
57 | |
6e4dfbec |
58 | ### Generation of makefiles |
9f33b387 |
59 | |
60 | Click **Generate** button and wait until the generation process is finished. |
a20cce39 |
61 | Then makefiles will appear in the build folder (e.g. <i> D:/occt/build-android </i>). |
62 | |
63 | ## Generation of makefiles using CMake from the command line |
64 | |
65 | Alternatively one may specify the values without a toolchain file: |
66 | |
67 | > cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=D:/DevTools/android-ndk-r13b -DCMAKE_ANDROID_STL_TYPE=gnustl_shared -DCMAKE_SYSTEM_VERSION=15 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_MAKE_PROGRAM=D:/DevTools/MinGW/bin/mingw32-make.exe -D3RDPARTY_DIR=D:/occt-3rdparty D:/occt |
68 | |
69 | @figure{/dev_guides/building/android/images/android_image006.png} |
9f33b387 |
70 | |
6e4dfbec |
71 | ## Building makefiles of OCCT |
9f33b387 |
72 | |
6e4dfbec |
73 | Open console and go to the build folder. Type "mingw32-make" (Windows) or "make" (Ubuntu) to start build process. |
74 | |
75 | > mingw32-make |
76 | or |
77 | > make |
78 | |
79 | |
80 | Parallel building can be started with using **"-jN"** argument of "mingw32-make/make", where N is the number of building threads. |
81 | |
82 | > mingw32-make -j4 |
83 | or |
84 | > make -j4 |
85 | |
86 | ## Install built OCCT libraries |
87 | |
88 | Type "mingw32-make/make" with argument "install" to place the libraries |
89 | to the install folder (see "OCCT Configuration" section of @ref occt_dev_guides__building_cmake "Building with CMake") |
90 | |
91 | > mingw32-make install |
92 | or |
93 | > make install |