Installation
Using native and cross-compiler toolchains to install Urho3D library
#
RequirementsFirst 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:
- CMake
- Git
- Rake
Optionally these as well:
- ccache - for speeding up the build
- Doxygen and Graphviz - for building documentation
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.
note
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.
- Android
- Apple
- Arm
- Linux
- RPI
- Web
- Windows
Remember to complete the Android SDK installation as per instructed by IDE.
Tested tool version: 29.0.2
Tested NDK version: 21.3.6528147
Tested Android gradle plugin version: 4.0.2
Required RAM size: 16 GB
You may use homebrew to install other missing development packages, like openssl.
Tested SDK version: 2.0.8
Both should already provide everything required.
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.
Linux | Mac | Windows | ||
---|---|---|---|---|
Target Platform | Android | |||
Apple | ||||
Arm | ||||
Linux | ||||
RPI | ||||
Web | ||||
Windows |
#
Setup ccacheIt is highly recommended having ccache
installed on Linux build environment. It reduces the recompilation time drastically. To activate it, simply export these environment variables:
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.
Finally, below is an easy way to verify the setup.
info
This is the reason Dockerized Build Environment is fast.
#
Install Urho3D Library#
Using CLIClone 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 ~/.urho3d/install/<platform>/
. 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.
caution
On Windows host the environment variables have to be set on separate command before invoking Rake task.
- Android
- Apple
- Arm
- Linux
- RPI
- Web
- Windows
#
Using IDEThe 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.
- Android Studio
- CLion
- Code::Blocks
- CodeLite
- IntelliJ IDEA
- Visual Studio
- Xcode
caution
Do not update the Android Gradle Plugin when being prompted, unless you know what you are doing.
- Choose "Open an Existing Project" or "Get from Version Control" if you haven't cloned the Urho3D project yet.
- 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.
- To run the sample app, press "Shift+F10".
- To install the Urho3D library for later use, locate the Gradle task called
publishToMavenLocal
and execute it.
caution
Disable the Gradle plugin and Gradle Native plugin as they may interfere and prevent proper project setup.
- Choose "Open" or "Get from VCS" if you haven't cloned the Urho3D project yet.
- In the "Open Project Wizard" or in the "CMake Settings", set the
CMAKE_INSTALL_PREFIX
accordingly in the "CMake options" field, e.g.:~/.urho3d/install/linux
when targeting Linux platform with GCC%USERPROFILE%\.urho3d\install\win
when targeting Windows platform with MSVC
- 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.
- To run the sample app, press "Shift+F10".
- To install the Urho3D library for later use, run "Install" under the "Build" menu.
- 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
. - 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. - // FIXME: Please submit PR to complete the install steps.
- 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
- 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. - // FIXME: Please submit PR to complete the install steps.
caution
Do not update the Android Gradle Plugin when being prompted, unless you know what you are doing.
- Choose "Open" or "Get from VCS" if you haven't cloned the Urho3D project yet.
- 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.
- To run the sample app, press "Shift+F10".
- To install the Urho3D library for later use, locate the Gradle task called
publishToMavenLocal
and execute it.
- Choose "Open a project or solution" or "Clone a repository" if you haven't clone the Urho3D project yet.
- 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:
- Disable the
URHO3D_PCH
build option - Set the
CMAKE_INSTALL_PREFIX
to%USERPROFILE%\.urho3d\install\win
- Disable the
- Save the above changes to allow CMake to reconfigure the build tree.
- 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.
- To run the sample app, press "Ctrl+F5".
- To install the Urho3D library for later use, run "Install Urho3D" under the "Build" menu.
- Generate a build tree using CMake's Xcode generator. One way to do it is by using rake task, like so:
rake cmake
for targeting macOSPLATFORM=iOS rake cmake
for targeting iOSPLATFORM=tvOS rake cmake
for targeting tvOS
- 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.
- 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.
- To run the sample app, press "โ+R".
- Select "Install" from the list of targets and press "โ+B" to actually install the Urho3D library for later use.