installation.mdx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. ---
  2. sidebar_position: 20
  3. ---
  4. import clsx from "clsx";
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import CompilerMatrix from '../../src/components/CompilerMatrix';
  8. import styles from './getting-started.module.scss';
  9. # Installation
  10. Using native and cross-compiler toolchains to install Urho3D library
  11. ## Requirements
  12. First prepares the build environment by installing a compiler toolchain for your target platform, and the required build tools. The compiler can be GCC, Clang, MSVC, MinGW-w64, or the one bundled in the SDK like Android SDK, Emscripten SDK, etc. On Ubuntu you can easily prepare the build environment by installing the `build-essential` package, on Windows by installing Visual Studio IDE, and on macOS by installing Xcode IDE. However, for cross-compiling usually you have to download and install the corresponding SDK manually. Make sure at the minimum the build environment has these build tools installed:
  13. - CMake
  14. - Git
  15. - Rake
  16. Optionally these as well:
  17. - ccache - for speeding up the build
  18. - Doxygen and Graphviz - for building documentation
  19. Although Urho3D project has included all required third-party libraries as source code, there may be system-level dependency packages that must be satisfied before Urho3D can be built from source successfully. The list below is by no mean comprehensive nor canonical, this is especially true on platforms with Linux operating system, but it should get you started.
  20. :::note
  21. This may change in the future when the project uses better package manager and Modern CMake. Ideally, the project should bootstrap itself with more ease than currently is.
  22. :::
  23. <Tabs
  24. className={styles.requirements}
  25. groupId={'target-platform'}
  26. defaultValue={'android'}
  27. values={[
  28. {label: 'Android', value: 'android'},
  29. {label: 'Apple', value: 'apple'},
  30. {label: 'Arm', value: 'arm'},
  31. {label: 'Linux', value: 'linux'},
  32. {label: 'RPI', value: 'rpi'},
  33. {label: 'Web', value: 'web'},
  34. {label: 'Windows', value: 'win'},
  35. ]
  36. }>
  37. <TabItem value={'android'}>
  38. <div className={clsx('textBlock', styles.fixedHeight)}>
  39. Install <strong>OpenJDK</strong>, and <strong>Android Studio</strong> or <strong>IntelliJ IDEA</strong>.<br/>
  40. Remember to complete the <strong>Android SDK</strong> installation as per instructed by IDE.<br/>
  41. <br/>
  42. Tested tool version: <strong>29.0.2</strong><br/>
  43. Tested NDK version: <strong>21.3.6528147</strong><br/>
  44. Tested Android gradle plugin version: <strong>4.0.2</strong><br/>
  45. <br/>
  46. Required RAM size: <strong>16 GB</strong>
  47. </div>
  48. </TabItem>
  49. <TabItem value={'apple'}>
  50. <div className={clsx('textBlock', styles.fixedHeight)}>
  51. Install <strong>Xcode</strong> and it should provide almost everything required.<br/>
  52. You may use <strong>homebrew</strong> to install other missing development packages, like <strong>openssl</strong>.
  53. </div>
  54. </TabItem>
  55. <TabItem value={'arm'}>
  56. ```bash
  57. # Urho3D only supports ARM platform on Linux OS, so it has the same deps as building Linux platform
  58. apt install \
  59. # !!! MESA is not needed on system with proprietary kernel module/driver !!!
  60. libgl1-mesa-dev \
  61. # Display server, still default to X11 at the moment
  62. libx11-dev \
  63. # Sound server, still default to PulseAudio at the moment
  64. libpulse-dev \
  65. # D-BUS and udev, for game controller hot-plugging
  66. libdbus-1-dev libudev-dev \
  67. # IME, optional for Chinese/Japanese/Korean text inputting
  68. libibus-1.0-dev \
  69. # SSL, optional for secure networking
  70. libssl-dev
  71. ```
  72. </TabItem>
  73. <TabItem value={'linux'}>
  74. ```bash
  75. # Building as 32-bit on a 64-bit host requires installation of 32-bit development packages too
  76. apt install \
  77. # !!! MESA is not needed on system with proprietary kernel module/driver !!!
  78. libgl1-mesa-dev \
  79. # Display server, still default to X11 at the moment
  80. libx11-dev \
  81. # Sound server, still default to PulseAudio at the moment
  82. libpulse-dev \
  83. # D-BUS and udev, for game controller hot-plugging
  84. libdbus-1-dev libudev-dev \
  85. # IME, optional for Chinese/Japanese/Korean text inputting
  86. libibus-1.0-dev \
  87. # SSL, optional for secure networking
  88. libssl-dev
  89. ```
  90. </TabItem>
  91. <TabItem value={'rpi'}>
  92. ```bash
  93. # This list was compiled for RPI3 in mind, with proprietary Broadcom Video Core proprietary driver
  94. # However, you can still use it for RPI4 by also installing MESA and X11 on top of it
  95. apt install \
  96. # Sound server, still default to PulseAudio at the moment
  97. libpulse-dev \
  98. # D-BUS and udev, for game controller hot-plugging
  99. libdbus-1-dev libudev-dev \
  100. # Generic Linux input driver
  101. libevdev2 \
  102. # IME, optional for Chinese/Japanese/Korean text inputting
  103. libibus-1.0-dev \
  104. # SSL, optional for secure networking
  105. libssl-dev
  106. ```
  107. </TabItem>
  108. <TabItem value={'web'}>
  109. <div className={clsx('textBlock', styles.fixedHeight)}>
  110. Install <strong>Emscripten SDK</strong> and it should already provide everything required.<br/>
  111. <br/>
  112. Tested SDK version: <strong>2.0.8</strong>
  113. </div>
  114. </TabItem>
  115. <TabItem value={'win'}>
  116. <div className={clsx('textBlock', styles.fixedHeight)}>
  117. Install <strong>Visual Studio</strong> together with <strong>Windows SDK</strong>.
  118. Alternatively, install <strong>MinGW-w64</strong>.<br/>
  119. Both should already provide everything required.
  120. </div>
  121. </TabItem>
  122. </Tabs>
  123. In general when cross-compiling the build system requires both the cross-compiler and native compiler toolchains to be installed on the host machine. This is because Urho3D build system builds the host-tool using the native compiler on the fly while cross-compiling the library for the target platform in one go. Check the table below on the supported cross-compiling scenario using Linux, Mac, and Windows host machine, respectively.
  124. <CompilerMatrix infoClassName={styles.infoFixedHeight}>
  125. | | |Linux|Mac|Windows|
  126. |---------------|-------|:---:|:-:|:-----:|
  127. |Target Platform|Android|Cross-compiler: Android NDK<br/>Native compiler: Clang or GCC|Cross-compiler: Android NDK<br/>Native compiler: Apple Clang|Cross-compiler: Android NDK<br/>Native compiler: MinGW-w64|
  128. | |Apple ||Native compiler: Apple Clang, can actually target macOS, iOS, and tvOS||
  129. | |Arm |Cross-compiler: ?, no need for native build<br/>Native compiler: Clang or GCC||
  130. | |Linux |Native compiler: Clang or GCC||
  131. | |RPI |Cross-compiler: ?, no need for native build<br/>Native compiler: Clang or GCC||
  132. | |Web |Cross-compiler: Emscripten EMCC<br/>Native compiler: Clang or GCC|Cross-compiler: Emscripten EMCC<br/>Native compiler: Apple Clang|Cross-compiler: Emscripten EMCC<br/>Native compiler: MinGW-w64|
  133. | |Windows|Cross-compiler: MinGW-w64<br/>Native compiler: Clang or GCC||Native compiler: MinGW-w64 or MSVC
  134. </CompilerMatrix>
  135. ### Setup ccache
  136. It is highly recommended having `ccache` installed on Linux build environment. It reduces the recompilation time drastically. To activate it, simply export these environment variables:
  137. ```bash title=~/.bash_profile
  138. export USE_CCACHE=1 CCACHE_SLOPPINESS=pch_defines,time_macros CCACHE_COMPRESS=1
  139. # When also targeting Android platform
  140. export ANDROID_CCACHE=$(which ccache)
  141. ```
  142. Adjust the `PATH` environment variable so that the ccache symlinks directory is in front of the `/usr/bin` entry, if it has not been automatically system-wide adjusted after installing the package. Basically by doing so, whenever a compiler command is about to be invoked, it would be "intercepted" and invoking one of the ccache symlinks instead.
  143. ```bash title=~/.bashrc
  144. PATH=$(whereis -b ccache |grep -o '[^ ]*$'):$PATH
  145. ```
  146. Finally, below is an easy way to verify the setup.
  147. ```bash
  148. [[ -L $(which gcc) ]] && echo "Good!" || echo "Oh no!"
  149. ```
  150. :::info
  151. This is the reason Dockerized Build Environment is fast.
  152. :::
  153. ## Install Urho3D Library
  154. ### Using CLI {#install-urho3d-library-using-cli}
  155. Clone the Urho3D project from the main branch, change directory to its project root, and execute **only one of the following commands** to install the library for your desired target platform. For simplicity's sake, this section provides instruction that install the Urho3D library into a default install location under user's home directory that does not require superuser privilege. Unless specified otherwise, the default install location is <code>~/.urho3d/install/<em>&lt;platform&gt;</em>/</code>. For example, on Linux platform with GCC it is `~/.urho3d/install/linux/`. For Clang on Linux platform it is `~/.urho3d/install/linux-clang/` to prevent clash with GCC. For Android platform, it is installed in `~/.m2/repository/` as AAR in Maven format.
  156. :::caution
  157. On Windows host the environment variables have to be set on separate command before invoking Rake task.
  158. :::
  159. <Tabs
  160. className={styles.cliInstall}
  161. groupId={'target-platform'}
  162. defaultValue={'android'}
  163. values={[
  164. {label: 'Android', value: 'android'},
  165. {label: 'Apple', value: 'apple'},
  166. {label: 'Arm', value: 'arm'},
  167. {label: 'Linux', value: 'linux'},
  168. {label: 'RPI', value: 'rpi'},
  169. {label: 'Web', value: 'web'},
  170. {label: 'Windows', value: 'win'},
  171. ]
  172. }>
  173. <TabItem value={'android'}>
  174. ```bash
  175. # When using Rake task, always install to Maven local repository
  176. PLATFORM=android rake build install
  177. # When using Gradle wrapper on Linux or Mac
  178. ./gradlew build publishToMavenLocal
  179. # When using Gradle wrapper on Windows
  180. gradlew.bat build publishToMavenLocal
  181. ```
  182. </TabItem>
  183. <TabItem value={'apple'}>
  184. ```bash
  185. # When targeting macOS, "PLATFORM=macOS" is the default on Mac
  186. rake build install
  187. # When targeting iOS
  188. PLATFORM=iOS rake build install
  189. # When targeting tvOS
  190. PLATFORM=tvOS rake build install
  191. ```
  192. </TabItem>
  193. <TabItem value={'arm'}>
  194. ```bash
  195. # When compiling natively on the ARM board, "PLATFORM=arm" should be already set
  196. rake build install
  197. # When cross-compiling on Linux host machine, substitute '?' accordingly
  198. ARM_ABI_FLAGS=? ARM_PREFIX=? ARM_SYSROOT=? PLATFORM=arm rake build install
  199. ```
  200. </TabItem>
  201. <TabItem value={'linux'}>
  202. ```bash
  203. # When using GCC, "PLATFORM=linux" is the default on Linux
  204. rake build install
  205. # When using Clang, override the "CC" and "CXX" environment variables
  206. CC=clang CXX=clang++ rake build install
  207. ```
  208. </TabItem>
  209. <TabItem value={'rpi'}>
  210. ```bash
  211. # When compiling natively on the RPI board, "PLATFORM=rpi" should be already set
  212. RPI_ABI=RPI3 rake build install
  213. # When cross-compiling on Linux host machine, substitute '?' accordingly
  214. RPI_ABI=RPI3 RPI_PREFIX=? RPI_SYSROOT=? PLATFORM=rpi rake build install
  215. ```
  216. </TabItem>
  217. <TabItem value={'web'}>
  218. ```bash
  219. # When using Rake task on Linux or Mac
  220. PLATFORM=web rake build install
  221. # When using Rake task on Windows
  222. set "PLATFORM=web" && rake build install
  223. ```
  224. </TabItem>
  225. <TabItem value={'win'}>
  226. ```bash
  227. # When compiling natively using VS, "PLATFORM=win" is the default on Windows
  228. rake build install
  229. # When compiling natively using MinGW-w64
  230. set "GENERATOR=mingw" && rake build install
  231. # When cross-compiling on Linux host machine, substitute '?' accordingly
  232. MINGW_PREFIX=? PLATFORM=mingw rake build install
  233. ```
  234. </TabItem>
  235. </Tabs>
  236. ### Using IDE {#install-urho3d-library-using-ide}
  237. The Urho3D project can be opened directly in the IDE that supports CMake or Gradle build system, like **Android Studio**, **CLion**, **IntelliJ IDEA**, and **Visual Studio**. For other IDEs, like **Xcode**, use CMake to generate the initial build tree first. This section tries to cover a few of the IDEs available in the market. The steps outlined here should be easily adaptable for other IDEs.
  238. <Tabs
  239. className={styles.ideInstall}
  240. groupId={'ide'}
  241. defaultValue={'android-studio'}
  242. values={[
  243. {label: 'Android Studio', value: 'android-studio'},
  244. {label: 'CLion', value: 'clion'},
  245. {label: 'Code::Blocks', value: 'code-blocks'},
  246. {label: 'CodeLite', value: 'codelite'},
  247. {label: 'IntelliJ IDEA', value: 'intellij'},
  248. {label: 'Visual Studio', value: 'visual-studio'},
  249. {label: 'Xcode', value: 'xcode'},
  250. ]
  251. }>
  252. <TabItem value={'android-studio'}>
  253. <div className={clsx('textBlock', styles.fixedHeight)}>
  254. :::caution
  255. Do not update the Android Gradle Plugin when being prompted, unless you know what you are doing.
  256. :::
  257. - Choose "Open an Existing Project" or "Get from Version Control" if you haven't cloned the Urho3D project yet.
  258. - After Gradle sync is completed, select "launcher-app" from the "Edit Run/Debug Configurations" drop down list, and press "Ctrl+F9" to build the sample launcher app. This should build the Urho3D library as well.
  259. - To run the sample app, press "Shift+F10".
  260. - To install the Urho3D library for later use, locate the Gradle task called `publishToMavenLocal` and execute it.
  261. </div>
  262. </TabItem>
  263. <TabItem value={'clion'}>
  264. <div className={clsx('textBlock', styles.fixedHeight)}>
  265. :::caution
  266. Disable the Gradle plugin and Gradle Native plugin as they may interfere and prevent proper project setup.
  267. :::
  268. - Choose "Open" or "Get from VCS" if you haven't cloned the Urho3D project yet.
  269. - In the "Open Project Wizard" or in the "CMake Settings", set the `CMAKE_INSTALL_PREFIX` accordingly in the "CMake options" field, e.g.:
  270. - `~/.urho3d/install/linux` when targeting Linux platform with GCC
  271. - `%USERPROFILE%\.urho3d\install\win` when targeting Windows platform with MSVC
  272. - Select "01_HelloWorld" or any other samples from the "Select Run/Debug Configuration" drop down list and press "Ctrl+F9" to build the sample app. This should build the Urho3D library as well.
  273. - To run the sample app, press "Shift+F10".
  274. - To install the Urho3D library for later use, run "Install" under the "Build" menu.
  275. </div>
  276. </TabItem>
  277. <TabItem value={'code-blocks'}>
  278. <div className={clsx('textBlock', styles.fixedHeight)}>
  279. - Generate a build tree using CMake's Code::Blocks generator. One way to do it is by using rake task, like so: `GENERATOR=codeblocks rake cmake`.
  280. - Open the "Urho3D.cbp" Code::Blocks project file in the build tree. In the above case, the project file can be found in `build/linux-codeblocks/` directory.
  281. - **// FIXME: Please submit PR to complete the install steps.**
  282. </div>
  283. </TabItem>
  284. <TabItem value={'codelite'}>
  285. <div className={clsx('textBlock', styles.fixedHeight)}>
  286. - Generate a build tree using CMake's CodeLite generator. One way to do it is by using rake task, like so: `GENERATOR=codelite rake cmake`
  287. - Open the "Urho3D.workspace" CodeLite workspace file in the build tree. In the above case, the workspace file can be found in `build/linux-codelite/` directory.
  288. - **// FIXME: Please submit PR to complete the install steps.**
  289. </div>
  290. </TabItem>
  291. <TabItem value={'intellij'}>
  292. <div className={clsx('textBlock', styles.fixedHeight)}>
  293. :::caution
  294. Do not update the Android Gradle Plugin when being prompted, unless you know what you are doing.
  295. :::
  296. - Choose "Open" or "Get from VCS" if you haven't cloned the Urho3D project yet.
  297. - After Gradle sync is completed, select "launcher-app" from the "Select Run/Debug Configuration" drop down list, and press "Ctrl+F9" to build the sample launcher app. This should build the Urho3D library as well.
  298. - To run the sample app, press "Shift+F10".
  299. - To install the Urho3D library for later use, locate the Gradle task called `publishToMavenLocal` and execute it.
  300. </div>
  301. </TabItem>
  302. <TabItem value={'visual-studio'}>
  303. <div className={clsx('textBlock', styles.fixedHeight)}>
  304. - Choose "Open a project or solution" or "Clone a repository" if you haven't clone the Urho3D project yet.
  305. - After CMake initial build tree is generated, open the "CMake Settings for Urho3D" under the "Project" menu, then in the "CMake variables and cache" section:
  306. - Disable the `URHO3D_PCH` build option
  307. - Set the `CMAKE_INSTALL_PREFIX` to `%USERPROFILE%\.urho3d\install\win`
  308. - Save the above changes to allow CMake to reconfigure the build tree.
  309. - Double click the "Folder View" in the "Solution Explorer", then select the "01_HelloWorld.exe" from the "Select Startup Item" drop down list and press "Ctrl+B" to build the sample app. This should build the Urho3D library as well.
  310. - To run the sample app, press "Ctrl+F5".
  311. - To install the Urho3D library for later use, run "Install Urho3D" under the "Build" menu.
  312. </div>
  313. </TabItem>
  314. <TabItem value={'xcode'}>
  315. <div className={clsx('textBlock', styles.fixedHeight)}>
  316. - Generate a build tree using CMake's Xcode generator. One way to do it is by using rake task, like so:
  317. - `rake cmake` for targeting macOS
  318. - `PLATFORM=iOS rake cmake` for targeting iOS
  319. - `PLATFORM=tvOS rake cmake` for targeting tvOS
  320. - Open the "Urho3D.xcodeproj" Xcode project file in the build tree. In the above case, the project file can be found in "build/macos", "build/ios", and "build/tvos", respectively.
  321. - Select "01_HelloWorld" or any other samples from the list of targets and press "⌘+B" to build the sample app. This should build the Urho3D library as well.
  322. - To run the sample app, press "⌘+R".
  323. - Select "Install" from the list of targets and press "⌘+B" to actually install the Urho3D library for later use.
  324. </div>
  325. </TabItem>
  326. </Tabs>