= Windows build instructions = As !VirtualBox is a cross platform project, we use a cross platform build system meaning that there won't be any Visual C++ project files that you can open and just build. Instead, you have to follow these steps but they aren't overly difficult. == Prerequisites == * '''Windows 10''', '''Windows 8.1''', '''Windows 8''' or '''Windows 7'''. * '''Visual Studio 2010 with service pack 1'''. * '''Windows Platform SDK v7.1''' [[BR]] http://www.microsoft.com/en-us/download/details.aspx?id=8279 [[BR]] ''Use `--with-sdk=` to specify the path for configure.vbs.'' * '''Windows Driver Development Kit (WDK) v7.1'''. [[BR]] http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11800 [[BR]] ''Use `--with-ddk=` to specify the path for configure.vbs.'' * '''MingW''' (32-bit Windows only): [[BR]] GCC 3.3.3: http://prdownloads.sf.net/mingw/gcc-core-3.3.3-20040217-1.tar.gz?download [[BR]] and http://prdownloads.sf.net/mingw/gcc-g++-3.3.3-20040217-1.tar.gz?download [[BR]] Runtime: http://prdownloads.sf.net/mingw/mingw-runtime-3.8.tar.gz?download [[BR]] W32API: http://prdownloads.sf.net/mingw/w32api-3.5.tar.gz?download [[BR]] Binutils: http://prdownloads.sf.net/mingw/binutils-2.13.90-20021006-2.tar.gz?download [[BR]] ''Note that neither GCC v3.4.2 nor v3.4.5 is currently able to build a working recompiler. So, make sure you are using the 3.3.x versions! '' [[BR]] ''Use `--with-mingw32` and `--with-w32api=` to specify the path to configure.vbs.'' * '''MingW''' (64-bit Windows only). [[BR]] GCC 4.5.4: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.5-release/x86_64-w64-mingw32-gcc-4.5.4-release-win64_rubenvb.7z/download [[BR]] ''Use `--with-mingw-w64=` to specify the path for configure.vbs.'' * '''Qt v5.6.x or later''' [[BR]] Note! This has to be built with the Visual C++ compiler mentioned above. [[BR]] ''Use `--with-qt5=` to specify the path for configure.vbs.'' * '''SDL v1.2.7 or later''' development package (VC6): [[BR]]http://www.libsdl.org/download-1.2.php [[BR]] ''Use `--with-libsdl=` to specify the path for configure.vbs.'' * the '''libxml2''' library. Sources and 32bit binaries can be downloaded from: [[BR]] http://xmlsoft.org/downloads.html [[BR]] http://xmlsoft.org/XSLT/downloads.html [[BR]] ''Use `--with-libxml2=` to specify the path for configure.vbs.'' * the '''zlib''' library. Grab the sources from: [[BR]] http://www.zlib.net/ [[BR]] * the '''cURL''' library. Grab the binaries from: [[BR]] http://curl.haxx.se/download.html [[BR]] (use the devel version ''without'' SSL support) [[BR]] ''Use `--with-libcurl=` to specify the path for configure.vbs.'' * '''OpenSSL 1.1.0'''. Grab the binaries from: [[BR]] https://slproweb.com/products/Win32OpenSSL.html [[BR]] ''Use `--with-openssl=` to specify the path for configure.vbs.'' * '''code signing utilities''' (64-bit Windows only). [[BR]] Normally part of the WDK: `certmgr.exe`, `makecert.exe`, `signtool.exe` and so on. * Optional: '''NSIS 2.51''', only needed if you want to build the Guest Additions including the installer. Required plugins: NsSCM, AccessControl, NsProcess and nsisunz. Grab the sources or setup from: [[BR]] https://sourceforge.net/projects/nsis/files/NSIS%202/2.51/ * Optional: '''gSOAP 2.8.36''', only needed if you want to build the webservice API server. Grab the sources from: [[BR]] http://sourceforge.net/projects/gsoap2/files/gSOAP/gSOAP%202.7.12%20stable/ * Optional: '''Python 2.7.x''', only needed if you want to build Python API bindings, both webservice and COM. Grab the binaries from: [[BR]] http://www.python.org/download/releases/2.7.10/ [[BR]] ''Use `--with-python=` to specify the path for configure.vbs.'' * Optional: '''Java SE 6 JDK''', only needed if you want to build Java API bindings, both webservice and COM. Grab the binaries from: [[BR]] http://www.oracle.com/technetwork/java/javase/downloads/index.html == Building !VirtualBox == 1. Change to the root directory and execute our configure script to setup your build environment: {{{ cscript configure.vbs }}} If the script finds all the tools necessary, it will output two files: `AutoConfig.kmk` containing information where to find the tools on your system and `env.bat`, a batch file to setup your environment for building !VirtualBox. You only have to execute this step once, unless something about your tools changes in which case you have to repeat the above step. Keep in mind that the script always overwrites the two generated files so you should not manually edit them. 2. Change to the root directory of the sources and enter our build shell environment: `env.bat`. 3. To manually override any tool or change Config.kmk settings, create LocalConfig.kmk in the root directory of the sources and place the setting there. For instance, to create a non-hardened build ('''only for testing!'''), add `VBOX_WITHOUT_HARDENING = 1` to LocalConfig.kmk. 4. To build a release package, type `kmk`. This produces the binaries in `out\win.x86\release\bin`. If you want to build a debug version, enter `kmk KBUILD_TYPE=debug`. === Using Visual C++ 2010 Express === If you don't have a Visual C++ license you can use [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express Visual C++ 2010 Express]. However, you will not be able to build any frontend because the !VirtualBox COM API - which all the other front ends program against - requires the Active Template Library (ATL) to build, and unfortunately the express edition doesn't include this (see http://msdn.microsoft.com/vstudio/express/support/faq/#vcpp). When doing the first build step, you have to add --with-VC-Express-Edition to the argument list: {{{ cscript configure.vbs --with-VC-Express-Edition }}} === Only for 64 bit builds: setting up self signing === Part 1: creating and installing the test certificate 1. Launch an elevated command line shell (Vista and later). 1. {{{makecert.exe -r -pe -ss my -n "CN=MyTestCertificate" mytestcert.cer}}} 1. {{{certmgr.exe -add mytestcert.cer -s -r localMachine root}}} 1. Start certmgr.exe and check that "!MyTestCertificate" is listed both under "Personal" and "Trusted Root Certification Authorities".[[BR]] ''If you have a self-signed certificate installed and upgrade to Windows 10 it might happen that the certificate is still listed under "Trusted Root Certification Authorities" but not under "Personal" anymore. In that case, remove the old certificate using certmgr.msc and create a new certificate (see above) and install it.'' 1. Keep the mytestcert.cer file in a safe place. Part 2: configuring the system to run test signed code (Vista and later) 1. Launch an elevated command line shell (Vista and later). 1. Run {{{Bcdedit.exe -set TESTSIGNING ON}}} on an elevated cmd.exe prompt. 1. {{{certmgr.exe -add mytestcert.cer -s -r localMachine root}}} 1. {{{certmgr.exe -add mytestcert.cer -s -r localMachine trustedpublisher}}} 1. Reboot. 1. Vista: "Test Mode" will appear in all four corners of the desktop and "Microsoft (R) Windows (R) (Build 6000)" will appear on the top. Windows 7: "Test ModeWindows 7Build 7600" will appear in the lower right corner. Part 3: building !VirtualBox with signing enabled 1. If you called the certificate something other than !MyTestCertificate you'll have make the appropriate overrides in {{{LocalConfig.kmk}}}. See the {{{Code Signing}}} section of Config.kmk for what can be overridden. 1. Add {{{VBOX_SIGNING_MODE=test}}} to {{{LocalConfig.kmk}}}. 1. Build (incremental is sufficient). == Running !VirtualBox == !VirtualBox requires devices drivers and COM classes to operate. Whenever these change, you will have to re-register them. In order to re-register the COM classes, execute {{{ comregister.cmd }}} which can be found in the output directory. Note that for this to work, `VBoxSVC.exe` must not be running, so use the Windows task manager to verify this. Usually `VBoxSVC.exe` terminates automatically after 5 seconds of inactivity (i.e. no client connection) but especially when developing, it might sometimes stay around. In case the COM classes change (this usually happens when the file `VirtualBox.xidl` is updated) and you forget to re-register the classes, weird problems may appear. In order to (re-)install the !VirtualBox kernel drivers, issue the following: {{{ loadall.cmd }}} Starting !VirtualBox is accomplished by invoking one of its frontends, such as {{{ VirtualBox.exe }}} or {{{ VBoxHeadless.exe }}}