Building VirtualBox OSE 5.0.0 on Windows 7 (x86)

正文转自 : https://forums.virtualbox.org/viewtopic.php?f=10&t=73799


I have successfully built and test signed VirtualBox OSE 5.0.0 on Windows 7 (x86) thanks for the information from this forum. I’d like to share my experience here.

1. Build environment: Windows 7 x86

2. Prerequisites for downloading

To be installed in the following recommended order:

2.1 Visual Studio 2010 Pro

2.2 Windows Platform SDK v7.1
http://www.microsoft.com/en-us/download/details.aspx?id=8279

2.3 Install Visual Studio 2010 Service Pack 1

2.4 Install Visual C++ 2010 SP1 Compiler Update for Windows SDK 7.1
http://www.microsoft.com/en-us/download/details.aspx?id=4422

2.5 Windows Driver Development Kit (WDK) v7.1
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11800

2.6 Python 2.7 (a version newer than 2.7 might cause building errors)

2.7 ActivePerl 5.20

2.8 MingW (32-bit Windows only):
GCC 3.3.3: http://prdownloads.sf.net/mingw/gcc-core-3.3.3-20040217-1.tar.gz?download
and http://prdownloads.sf.net/mingw/gcc-g++-3.3.3-20040217-1.tar.gz?download
Runtime: http://prdownloads.sf.net/mingw/mingw-runtime-3.8.tar.gz?download
W32API: http://prdownloads.sf.net/mingw/w32api-3.5.tar.gz?download
Binutils 2.19: http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/binutils-2.19/

Note: All the packages need to be extracted and merged to the same root folder (e.g., C:\VBox\MinGW32-3.3.3\bin, C:\VBox\MinGW32-3.3.3\include, C:\VBox\MinGW32-3.3.3\lib)
Set C:\VBox\MinGW32-3.3.3\bin in PATH

2.9 SDL v1.2.15 or later development package http://www.libsdl.org/download-1.2.php

3. Prerequisites for building

3.1 Build QT 4.7.x or later
- 1)Download Qt-4.7.3 source code (qt-everywhere-opensource-src-4.7.3.tar.gz) from https://download.qt.io/archive/qt/4.7/ and extract to ..\qt-4.7.3
- 2)Download jom from https://wiki.qt.io/Jom and extract to ..\VBox\jom (“jom” is a clone of nmake to support the execution of multiple independent commands in parallel.)
- 3)Update the PATH variable to include ..\qt-4.7.3\bin
- 4)Open a VS2010 command prompt (Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt)
- 5)Go to the source code directory of qt 4.7.3 (..\qt-4.7.3)
- 6)Set QMAKESPEC to the corresponding VS version

e.g., set QMAKESPEC=C:\VBox\qt-4.7.3\mkspecs\win32-msvc2010
  • 7) Run configure command:
configure -debug-and-release -opensource -platform win32-msvc2010
  • 8.) Run build commands:
Option 1: using jom – 
C:\dev\VBox\qt-4.7.3>..\jom\jom.exe -j N
(Where N is number of CPU cores you want to utilize for Qt compilation. Larger is better.
Option 2: using nmake – 
C:\dev\VBox\qt-4.7.3>nmake

3.2 Build Openssl 1.0.1 or later

  • 1) Download source code fromhttp://olex.openlogic.com/packages/openssl/1.0.1p#package_detail_tabs
    * (Note: The header files under “..\openssl-xxx\include\openssl” always have 0 size when the package is downloaded. They are populated with links during the make phase.)*
  • 2) Open a VS2010 command prompt
  • 3) Build Openssl
    i. Install ActivePerl (e.g., at C:\Perl)
    ii. Update the PATH variable to include ..\Perl\bin
    iii. For 32-bit build: go to the OpenSSL source folder for (e.g. cd C:\VBox\openssl-1.0.1p) to run configure commands:
perl Configure VC-WIN32 --prefix=C:\VBox\openssl-1.0.1p\output
ms\do_ms
nmake -f ms\ntdll.mak 
nmake -f ms\ntdll.mak install

Note: The build outputs will be in C:\VBox\openssl-1.0.1p\output

3.3 Build cURL

  • 1) Download source code from http://curl.haxx.se/download.html
  • 2) Open a VS2010 command prompt
  • 3) Go to the directory of the source code (e.g., C:\VBox\curl-7.35.0) and set OPENSSL_PATH to the openssl directory (e.g., set OPENSSL_PATH=….\openssl-xxx)
  • 4) Build commands:
pushd lib
nmake /f Makefile.vc10 cfg=release-dll

Note: vc10 for Visual Studio 2010. The build outputs will be in ..\lib\release-dll
What VBox requires from cURL build output are
..\curl-7.35.0\include
..\ curl-7.35.0\lib\release-dll\libcurl.dll
..\ curl-7.35.0\lib\release-dll\libcurl_imp.lib (rename libcurl_imp.lib to libcurl.lib)

4 Build VirtualBox

4.1 Get source code of VBox (e.g., 5.0.0) from http://download.virtualbox.org/virtualbox/5.0.0/VirtualBox-5.0.0.tar.bz2 and extract to a folder (e.g., C:\VBox\VirtualBox-5.0.0)
4.2 Install Python and ActivePerl if they are not present
4.3 Open a VS2010 command prompt
4.4 Configure required libraries for VBox building:

C:\VBox\VirtualBox-5.0.0>cscript configure.vbs --with-libSDL=C:\VBox\SDL-1.2.15 --with-openssl=C:\VBox\openssl-1.0.1p\output --with-libcurl=C:\VBox\curl-7.35.0 --with-QT4=C:\VBox\qt-4.7.3 --with-MinGW32=C:\VBox\MinGW32-3.3.3

Note: VBox complains if the version of MinGW is too new. Version 3.3.3 works.
If the configure command doesn’t succeed, please check “..\VirtualBox-5.0.0\configure.log” for errors.
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.

4.5 To build an unhardening version of VBox, add the following in “..\VirtualBox-5.0.0\LocalConfig.kmk” (If LocalConfig.kmk doesn’t exit, create one).

VBOX_WITH_HARDENING :=   

4.6 Add the following in “..\VirtualBox-5.0.0\Makefile.kmk”

VBOX_BLD_PYTHON=C:\Python27\python.exe

4.7 Build VBox

env.bat
kmk
kmk KBUILD_TYPE=debug (for debug version)

5 Install VirtualBox

Once VirtualBox is built successfully, there are a few steps to do before executing VirtualBox.exe:

5.1 Copy the following libraries to the same directory of VirtualBox.exe (e.g., C:\VBox\VirtualBox-5.0.0\out\win.x86\release\bin) or..\system32:

libcurl.dll (e.g.,  from C:\VBox\curl-7.35.0\lib)
libeay32.dll (e.g., from C:\VBox\openssl-1.0.1p\output\bin)
ssleay32.dll (e.g., from C:\VBox\openssl-1.0.1p\output\bin)
QtCore4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtGui4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtNetwork4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtOpenGL4.dll (e.g., from C:\VBox\qt-4.7.3\bin)

5.2 Open an elevated VS2010 command prompt and go to the same directory as VirtualBox.exe to run the following commands:

comregister.cmd
loadall.cmd

Note: env.bat under ..\ VirtualBox-5.0.0\ needs to be run before loadall.cmd if it’s not been run under the current command session.

5.3 Run VirtualBox.exe to load VirtualBox

6 Signing VBox

To create a signed version of VBox, steps in Section 3-5 need to be modified as follows:
6.1 creating and installing the test certificate
6.1.1 Launch an elevated command line shell
6.1.2 makecert.exe -r -pe -ss my -n “CN=MyTestCertificate” mytestcert.cer
6.1.3 certmgr.exe -add mytestcert.cer -s -r localMachine root
6.1.4 Start certmgr.exe and check that “MyTestCertificate” is listed both under “Personal” and “Trusted Root Certification Authorities”.
6.1.5 Keep the mytestcert.cer file in a safe place

6.2 Configuring the system to run test signed code
6.2.1 Launch an elevated command line shell
6.2.2 Run the following on an elevated cmd.exe prompt

Bcdedit.exe -set TESTSIGNING ON

6.2.3 Run

certmgr.exe -add mytestcert.cer -s -r localMachine root
certmgr.exe -add mytestcert.cer -s -r localMachine trustedpublisher

6.2.4 Reboot
6.2.5 Windows 7: “Test ModeWindows 7Build 7601” will appear in the lower right corner

6.3 Building prerequisite dlls for VBox
6.3.1 In order to be loaded by signed VBox, the prerequisite dlls should get a link option “Integrity Check” set in the dll headers. Edit the following configure files before building the prerequisites in Setion 3 to get the right link headers.
in ..\qt-4.7.3\mkspecs\win32-msvc2010\qmake.conf, edited the value of flag QMAKE_LFLAGS_DLL to

"QMAKE_LFLAGS_DLL = /DLL /INTEGRITYCHECK"

in ..\openssl-1.0.1p\ms\ntdll.mak, change to the following

"LFLAGS=/nologo /subsystem:console /opt:ref /debug /INTEGRITYCHECK" 
"MLFLAGS= /nologo /subsystem:console /opt:ref /debug /dll /INTEGRITYCHECK"  

note: ntdll.mak got over written after command “ms\do_ms”. Pls do the changes after the command.

In ..\curl-7.35.0-src\curl-7.35.0\lib\Makefile.vc10, change to the following

"LNKDLL = link.exe /DLL /INTEGRITYCHECK"

6.3.2 Follow the build instruction in Section 3 to build the prerequisites.

6.3.3 Sign the built dlls using command

Signtool.exe sign –v [name].dll

Sign the following:

libcurl.dll (e.g.,  from C:\VBox\curl-7.35.0\lib)
libeay32.dll (e.g., from C:\VBox\openssl-1.0.1p\output\bin)
ssleay32.dll (e.g., from C:\VBox\openssl-1.0.1p\output\bin)
QtCore4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtGui4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtNetwork4.dll (e.g., from C:\VBox\qt-4.7.3\bin)
QtOpenGL4.dll (e.g., from C:\VBox\qt-4.7.3\bin)

6.3.4 Run the following command to check the Integrity Check flag has been set in dll headers:

Link.exe /dump /headers [name].dll

Check under “DLL characteristics”, it should have “Check integrity” present.

6.3.5 Copy and paste the above signed dlls to the same directory of VirtualBox.exe

6.4 Building VirtualBox with signing enabled
6.4.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
6.4.2 Remove the following from LocalConfig.kmk

VBOX_WITH_HARDENING := 

6.4.3 Add the following to LocalConfig.kmk

VBOX_SIGNING_MODE=test

6.4.4 Copy Signtool.exe (e.g. from C:\WinDDK\7600.16385.1\bin\x86) and Inf2Cat.exe (e.g. from C:\WinDDK\7600.16385.1\bin\selfsign) to ..\VBox\tools\win.x86\selfsign\r1
6.4.5 Build VBox (incremental is sufficient) – refer to Section 4


7. 问题备注:

  1. 如果报错提示 缺少 ld.exe as.exe objdump.exe 等, 它在 binutils-2.19.1-mingw32-bin.tar.gz 中可以找到,下载并覆盖安装即可。

  2. 如果是中文版vs 2010 需要修改 vbs 中的 几个英文字符串为中文。

    if (strPathVCCommon <> "") Then
    EnvAppend "PATH", ";" & strPathVCCommon & "/IDE"
    end if
    if Shell(DosSlashes(strPathVC & "/cl.exe"), True) <> 0 then
    MsgError "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed."
    exit sub
    end if
    if (InStr(1, g_strShellOutput, "编译器 16.") <= 0) _
    And (InStr(1, g_strShellOutput, "17.00") <= 0) then
    MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
    exit sub
    end if
    '
    ' Ok, emit build config variables.
    '
    if InStr(1, g_strShellOutput, "编译器 16.") > 0 then
    CfgPrint "PATH_TOOL_VCC100 := " & g_strPathVCC
    CfgPrint "PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100)"
    CfgPrint "PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100)"
    if LogFileExists(strPathVC, "atlmfc/include/atlbase.h") then
    PrintResult "Visual C++ v10 with ATL", g_strPathVCC
    elseif LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h")

3.多个文件存在编码问题.


详细解决方法 :
http://www.cnblogs.com/cxun/archive/2013/03/12/2956175.html
http://m.oschina.net/blog/189699

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
您好!为了安装Windows7,您需要按照以下步骤操作: 1. 首先,下载并安装VirtualBox软件。您可以从VirtualBox官方网站(https://www.virtualbox.org/)上下载适用于您的操作系统的安装程序。 2. 安装VirtualBox后,打开软件并点击"新建"按钮创建一个新的虚拟机。 3. 在新建虚拟机向导中,输入虚拟机的名称,并选择"Microsoft Windows"作为操作系统类型,"Windows7 (64-bit)"或"Windows7 (32-bit)"作为版本,具体根据您的Windows7镜像文件来选择。 4. 分配虚拟机的内存大小。建议至少分配2GB的内存给Windows7虚拟机,但您也可以根据您的系统配置和需求进行调整。 5. 创建虚拟硬盘。选择"创建虚拟硬盘"选项,并按照向导中的指示进行设置。在这一步中,您可以选择创建动态分配或固定大小的虚拟硬盘,并为其分配存储空间。 6. 完成虚拟机的创建后,在VirtualBox主界面中选择您刚刚创建的虚拟机,然后点击"设置"按钮。 7. 在虚拟机设置中,选择"存储"选项卡,并点击"控制器:IDE"下的"空白"光驱图标。 8. 在右侧的"属性"窗口中,点击光驱图标旁边的小光盘图标,并选择"虚拟光盘文件"。 9. 浏览并选择您下载的Windows7 ISO镜像文件,并点击"确定"按钮。 10. 确认设置后,关闭虚拟机设置窗口,并启动虚拟机。此时,Windows7安装程序将会启动。 11. 按照Windows7安装程序的指示完成安装过程。 请注意,您需要拥有合法的Windows7许可证才能安装和使用Windows7操作系统。希望这些步骤能够帮助您成功安装Windows7!如果您有任何其他问题,请随时提问。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值