NOTICE: Account creation on the wiki has been temporarily disabled until the wiki is moved to OpenID. If you need an account before then, please request one here: http://forum.xbmc.org/showthread.php?tid=165868
HOW-TO:Compile XBMC for Windows
| |
This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions. |
| |
NOTICE: Needs merging with HOW-TO:Compile XBMC for Windows using Git |
- Note: XBMC is open source (GPL) software and as so the source code is available for anyone to modify and/or compile (under the rules of the GPL).
Contents |
1 Prerequisites
- An x86 computer with supported operating-system (Windows 7 x64/x32 bit, Vista and XP should all work) installed
- Correctly installed graphics device-drivers from the manufacturer's website, (the latest is often the best choice).
- Visual C++ 2010 (express edition is fine) or higher
- Microsoft DirectX SDK dated August 2009 or later
- Download the June 2010 version here
- Git for Windows (latest version available is fine)
- Nullsoft sciptable install system (required for buildsetup.bat)
- Java Runtime Environment (JRE)
- A git client for Windows, for example TortoiseGit available here: http://code.google.com/p/tortoisegit/
2 Getting the sources
Assuming you are using TortoiseGit:
- Before starting you must read the following page: Git Usage
- Right click in a directory of your choice and select Git Clone...
- Enter git://github.com/xbmc/xbmc.git for the Url.
- Note: there are many ways to setup a local git repository. See Git Usage for more details or git tutorials on the internet for advanced uses.
- Enter a name (e:\Coding\Windows\xbmc for example) for the destination directory into Directory
- Sit back and eat a sandwich. Downloading the source could take around 20 minutes or more (expect about 200 MB).
3 Setting up the build Environment
To setup the build environment, several scripts must be called.
- DownloadBuildDeps.bat (located in the folder project\BuildDependencies).
- Unfortunately, there is no warning given if an archive fails to download. If you try to compile and get some errors about a header file missing, this could be the reason why. If a library fails to download, it is probably a result of the URI changing and a developer should be notified (for example, libcurl in r35685). If you can figure out which package is failing and are able to download it, then simply sticking it in project\BuildDependencies\downloads and running DownloadBuildDeps.bat again should get you past that obstacle.
- DownloadMingwBuildEnv.bat (also located in the folder project\BuildDependencies) to download the necessary items for building the ffmpeg libraries.
- buildmingwlibs.bat (in project\Win32BuildSetup). This will build the ffmpeg libraries.
- BuildSetup.bat (in project\Win32BuildSetup) ONLY if you would like to build a package ready to go. In this case, BuildSetup.bat automatically calls buildmingwlibs.bat for you. To debug, or to build in Visual Studio directly, follow next steps.
- extract_git_rev.bat - this optional script, also called by BuildSetup.bat, will show the git revision in the system information window. Except for production purposes, it isn't recommended that you run this script.
4 Building the mingw-compiled dependencies
- Execute buildmingwlibs.bat in "path\to\xbmc\project\Win32BuildSetup"
(you can skip this step if you only want to create a Setup installer, as it is included in the installer build script)
If you run into a "cl: Command not found"-error, edit buildmingwlibs.bat and change the line 'call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat' into the absolute path. For example: 'call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"'
5 Building XBMC for Windows (DirectX)
- Run VC++ 2010 Express
- Load the XBMC\project\VS2010Express\XBMC for Windows.sln solution file.
- Choose the project to build:
- Debug or Release (obviously Debug if you wish to actually do development work).
- Choose DirectX (OpenGL is deprecated).
- Build the project
6 Running/Debugging XBMC from Visual C++ Express 2010
To run XBMC from Visual Studio you need to set a variable so XBMC knows where to look for files.
- Open up the XBMC project properties from the solution explorer.
- Goto the Debugging settings and enter "XBMC_HOME=C:\Dev\XBMC" (without quotes) in the "Environment" field, where C:\Dev\XBMC is the path where your XBMC root is (containing language/skin/system/userdata folders etc.)
Additionally you may need to copy SDL dll's to run.
- Copy *.dll from "project\Win32BuildSetup\dependencies" to the build directory, e.g. "project\VS2010Express\XBMC\Debug (DirectX)"
You should now be all set to start developing for XBMC and submitting those patches.
7 Additional hints
If you want to do release builds for your personal use and/or testing, go into your source dir and browse into \project\Win32BuildSetup
There are several batch files in there that provide the tasks doing the build. Use BuildSetup.bat to get it done for you. If you want to create the setup installer (i.e. XBMCSetup-Revxxxxx-gl.exe) you need to install the NSIS Installer ( http://nsis.sourceforge.net/Main_Page ) to your system. Please note that you still need to set up VC++ 2010 as mentioned above before you can use these batches.
There are several minor (and major) issues that could come in your way to prevent you from doing a successful (release) build. Those are:
- 1. getting multiple error messages telling that "git_rev.h" is missing while trying to compile a release build
- 2. getting several error messages by windows that some dll files are missing while trying to create the textures for the default skins.
- 3. getting build errors about a missing d3dx9.h file
solutions:
1. The extract_git_rev.bat script ran into trouble. At this time two git clients are supported: msysgit and TortoiseGit. The directory containing git.exe or tgit.exe must be in the PATH environment variable in order to be recognized by the script.
2. Several dlls are involved in the process of creating texture.xbt for the default skins. Those are
SDL.dll SDL_image.dll jpeg.dll libpng1.dll zlib.dll
SDL_image.dll can be downloaded from http://www.libsdl.org/projects/SDL_image/ and the other libraries can be found in path\to\xbmc\project\Win32BuildSetup\dependencies.
Make sure these libraries are accessible inside your %PATH% environment so the batch will find them e.g.
set PATH=path\to\xbmc\project\Win32BuildSetup\dependencies;%PATH%
3. Make sure the DirectX SDK is installed. A reboot may be required before Visual Studio can use the SDK.
4. IF you see "'java.exe' is not recognized as an internal or external command" messages during building, edit tools\codegenerator\GenerateSWIGBindings.bat and edit java.exe to a absolute path.
8 Debugging a crash with a minidump
If you have a minidump (*.dmp) file of XBMC crashing on Windows you can use Visual Studio to extract valueable information about the cause of the crash from it. There are two requirements for being able to load a minidump in Visual Studio
- You need to have the Program Database file (*.pdb) of the build which crashes
- You need to be able to install the build which crashes
In the requirements mentioned above it's not enough to be able to compile a similar build with the same sources, it has to be the exact same build. For XBMC's nightly builds the PDB files are available from the same place where the XBMC installers can be downloaded. After you have installed the same build and downloaded both the PDB and the minidump file you need to copy the PDB file into the installation directory and rename it to "XBMC.pdb" (matching "XBMC.exe"). The location of the minidump does not matter. With a double-click on the DMP file it will open in Visual Studio.
Either click on the "Set symbol paths" link in the "Minidump File Summary" view or go to Debug -> Options and Settings -> Debugging -> Symbols. In the "Symbols file (.pdb) locations" list add the path to XBMC's installation directory (where you also stored the PDB) and close the dialog with OK. Now click on the "Debug with Native Only" link and Visual Studio will start the debugger and jump to the location where XBMC crashed. If Visual Studio asks you for the location of a specific source (.cpp) file you need to point it to your local XBMC source code. Once in the debugger you will see on which line XBMC crashed and you can also inspect the variable values of the crash context.
9 Compile error on Win8
If you get the message that "Microsoft.Cpp.Default.props" can't be found there's probably a key missing in the registry. MSBuild uses the VCTargetsPath to locate default cpp properties but cannot because the registry lacks this key.
Check for the key
- Launch regedit
- Navigate to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersion\4.0
- Inspect VCTargetsPath key. The value should be "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\"
To fix
- Launch regedit
- Navigate to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersion\4.0
- Add string key VCTargetsPath key
- Set Value to "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\"
