Welcome to the Urho3D beginner build guide!
This Guide describes how to create and build Urho3D from source via CodeBlocks Project files or via direct Makefiles. There are five steps and step four is the only different one.
The Guide used the following programs (links below):
- Urho3D (1.32)
- CMake (3.1.3)
- MinGW (4.9.2 32bit)
- CodeBlocks (Nightly 2015-01-31)
- Windows 7
Other program versions should work too and other programs (like Visual Studio instead of MinGW) would be similiar. [WIKINOTE: Maybe there could be different sections to split paths for like different IDEs]
1. Download[]
- Urho3D: https://github.com/urho3d/Urho3D/archive/1.32.zip
- CMake: http://www.cmake.org/download/ (direct to setup: http://www.cmake.org/files/v3.1/cmake-3.1.3-win32-x86.exe)
- MinGW: http://sourceforge.net/projects/mingw-w64/?source=typ_redirect
- CodeBlocks: http://forums.codeblocks.org/index.php/topic,19964.0.html
(I picked the latest nightly because the last stable is quite old.
These nightly builds can sometimes be unstable, this one seems fine though. IMPORTANT: you also need the two other files in the forum post: wxWidget DLL and mingw10m.dll. You may want to get a newer nightly or latest stable from http://www.codeblocks.org/downloads)
2. Install/Unpack[]
- Install CMake and MinGW. I chose these settings for MinGW:
- Unpack CodeBlocks and put the two extra files also in that folder.
- Unpack Urho3D.
3. Build Codeblocks project files or a Makefile using CMake[]
- Start CMake-GUI, select the "Source" folder inside the folder Urho3D
has been unpacked into and choose a build path (where CMake should put it's output in). This may now look like this:
- Press "Configure". This should open two windows:
Alternative: You can also choose "MinGW Makefiles" if you want to use Makefiles directly (without CodeBlocks Projects). Depending on your CMake version, there may be no "CodeBlocks - MinGW Makefiles" available. Though this "CodeBlocks - MinGW Makefiles" option does also generate Makefiles, which are used in the alternate step 4.
3. This may generate errors (it did that for me) and fill the lower window. It may now look like this:
Note: On one of my machines CMake displayed several errors about a missing "libwinpthread-1.dll". This file is located inside the compiler path specified above (here C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/bin). Copying this file to a folder inside the PATH variable or modifying the PATH variable to include the compiler path should fix this problem (did it for me, see [] for details about the variable).
4. The red lines are missing paths. You need to select a specific file from MinGW there. Like this:
Giving him the path to "make" seems to be enough. "sh" doesn't seem to be required.
5. After clicking "Configure" again, CMake should be able to finish this step and display all possible options including options specific to Urho3D. Select the flags that you want Urho3D to build with. URHO3D_DOCS didn't work for me (error in the build step below) so I unchecked that / kept it unchecked. I used these flags:
6. Press Generate. This generates files in the build-folder and should show "Generate done" in the lower window when finished.
4. (easy) Prepare Build with CodeBlocks using the generated project files[]
There should be a CodeBlocks project file called "Urho3D.cbp" inside the Build folder. Open that with CodeBlocks.
4. (alternative) Prepare Build with CodeBlocks using the generated Makefiles directly[]
1. Open CodeBlocks. It may ask for a default compiler, select GNU GCC Compiler.
2. Select File->New->Project -> Empty Project -> Go.
3. Enter some title (like Urho3D_cb) and select a folder to put the project file into:
4. Select GNU GCC Compiler again. IMPORTANT: Rename the "Release" configuration into "all". The configuration (also called target) needs to have the same name as the target inside the Makefile, which we are going to select. (The target could also be renamed after creating a project.)
There should now be an empty project on the left side in your workspace.
5. Select the "all" target at the combo box marked with the red 1:
Right click on the new project in the workspace (at the red 2), and select "Properties..." at the bottom. Check "This is a custom Makefile" (near the red 3) and select your build directory (which you selected in CMake before) as the Execution directory (there should be a file called "Makefile" in there, which was created by CMake).
5. Build[]
Build the the project by choosing Build->Build in the menu bar or by pressing Ctrl+F9. This may take quite some time.
Codeblocks should be filling the "Build log" at the bottom with messages like:
... [ 59%] Building CXX object Engine/CMakeFiles/Urho3D.dir/Graphics/OpenGL/OGLTextureCube.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/Graphics/OpenGL/OGLVertexBuffer.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/Input/Input.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/IO/Compression.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/IO/Deserializer.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/IO/File.cpp.obj [ 60%] Building CXX object Engine/CMakeFiles/Urho3D.dir/IO/FileSystem.cpp.obj ...
When this is finished, the "Build log" looks like this:
... [100%] Building CXX object Samples/37_UIDrag/CMakeFiles/37_UIDrag.dir/UIDrag.cpp.obj Linking CXX executable C:\Urho3D\Urho3D\Bin\37_UIDrag.exe [100%] Built target 37_UIDrag Scanning dependencies of target OgreBatchConverter [100%] Building CXX object Extras/OgreBatchConverter/CMakeFiles/OgreBatchConverter.dir/OgreBatchConverter.cpp.obj Linking CXX executable C:\Urho3D\Urho3D\Bin\OgreBatchConverter.exe [100%] Built target OgreBatchConverter Process terminated with status 0 (15 minute(s), 17 second(s)) 0 error(s), 4 warning(s) (15 minute(s), 17 second(s)) Build log saved as: file://C:/Urho3D/codeblocks_project/Urho3D_cb_build_log.html
and you are done with building Urho3D!
You can now go to the "Bin" folder inside your Urho3D folder and start some of the freshly build samples (if you build them):
You may want to continue with the first project tutorial.