Build SSCLI20 under VS2008 full Document (完全手冊)
以前build過幾次sscli2都成功了,這次換了個新的環境,沒想到出了一大堆的問題。折騰了半天,最終搞定,把解決問題的過程和方法都記錄下來。
首先說說build的過程中參考過的鏈接和資源。
1. 首先就是sscli自帶的文檔:Building the Shared Source CLI 2.0 and C# 2.0 Source Tree
(\sscli20\docs\buildtools\building_sscli.html),這里詳細介紹了build的過程,build中需要用到的工具和方法,等。
2. Shared Source CLI 2.0 Build Environment Variable Scripts(env.bat, env.csh, env.sh)(sscli20\docs\buildtools\env.html),詳細介紹了設置環境變量和buildall等工具的參數設置。Build中用到的其它工具的參考說明可以到sscli20\docs\buildtools這個目錄下找到。
3. 張羿的“.NET / Rotor 源碼研究1 - Building Rotor”,鏈接地址為:
http://blog.csdn.net/ATField/archive/2006/12/31/1471465.aspx
4. Jeremy Kuhne's “SSCLI 2.0 and Visual Studio 2008”,URL:
http://blogs.msdn.com/jeremykuhne/archive/2008/02/19/sscli-2-0-and-visual-studio-2008.aspx
5. Xwang的在Visual Studio 2008的環境下Build SSCLI 2.0(ROTOR),URL:
http://www.rzrgm.cn/zhzkl/archive/2008/05/13/1194258.html
6. Building SSCLI20 (Rotor) in VS2008,URL:
http://code.msdn.microsoft.com/BuildRotorInVS2008,by codekaizen
還有就是發現問題和解決問題的過程了.
首先,如果是需要再AMD的系列CPU上面Build,最好參考codekaizen提供的源碼修改包。其正對AMD的cpu再上面的4上面做了一些小的修改:
l In the modified win.env.bat file, I added @set PROCESSOR_ARCHITECTURE=x86 to line 106 to get it to build under AMD64. The build environment was X86 already, but apparently it wasn't enough.
l On line 144 of the modified tools\nmake\def.mak file, comment out #CFLAGS = $(CFLAGS) -Wp64, since the flag is deprecated.
l This one didn't seem right, but it was the most expedient: comment out lines 73 to 79 in pal\exception.c, which is the declaration of a function RtlUnwind which is apparently never used or defined. It could be some platform specific call, which works on a Windows machine.
其中如果是再intel的cpu上面,按照他說的comment了TrlUnwind,會出現:
d:\rotor\sscli20\pal\win32\exception.c(143) : error C2094: label 'RtlUnwind' was undefined
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'
這樣的錯誤,這個時候,把他再pal\win32的exception.c第73行對
/*
WINBASEAPI
VOID
WINAPI
RtlUnwind(PVOID TargetFrame,
PVOID TargetIp,
PVOID ExceptionRecord,
PVOID ReturnValue);
*/
的注釋,去掉即可。
另外說說VC開發環境變量設置的問題。
修改sscli源碼讓其在VS2008下面運行的第一步,就是要修改MSVCDIR和MSDEVDIR兩個環境變量。在sscli20\docs\buildtools\env.html這個地方,可以看到MSVCDir的定義,指向的是:%VCINSTALLDIR%\VC,指向的是Microsoft Visual C++ 2005 root directory。
如果不修改msvcdir變量,在env debug的時候,就會報出msvcdir沒有設置的錯誤。
修改\sscli20\win.env.bat:
1. change %VS80COMNTOOLS% on line 37 to %VS90COMNTOOLS%
2. after line 42, insert the following:
REM Set the SDK path
if "%ROTOR_WINSDKDIR%"=="" set ROTOR_WINSDKDIR=%WindowsSdkDir%
if "%ROTOR_WINSDKDIR%"=="" set ROTOR_WINSDKDIR=%MSVCDIR%\PlatformSDK
call :ShortName "%ROTOR_WINSDKDIR%"
set ROTOR_WINSDKDIR=%RESULT%
想這樣因為環境變量引起的問題還挺多,可以參考Jeremy Kuhne的文章一一修改。另外,也可以看看上面的幾個鏈接中他們在build的時候遇到的問題與解決方法。
到Xwang的blog上面把他的那個包給下載下來,然后直接覆蓋到sscli中,如果你出現code編碼的保存方式不同造成的錯誤,請參考zhangyi的文章修改OS的location。如果你出現不能正確識別操作系統的錯誤,也請參考zhangyi的那篇文章。如果你出現一些環境變量的莫名其妙的問題,請參考xwang的解決方法。
運行env debug和buildall,
十分鐘之后,build完成好了,就可以運行:
D:\Rotor\sscli20>cd binaries.x86dbg.rotor
D:\Rotor\sscli20\binaries.x86dbg.rotor>csc ..\samples\hello\hello.cs
Microsoft (R) Shared Source CLI C# Compiler version 2.0.0001
for Microsoft (R) Shared Source CLI version 2.0.0
Copyright (C) Microsoft Corporation. All rights reserved.
D:\Rotor\sscli20\binaries.x86dbg.rotor>clix hellp.exe
hellp.exe: The system cannot find the file specified.
D:\Rotor\sscli20\binaries.x86dbg.rotor>clix hello.exe
Hello World!
Enjoy Rotor, Enjoy Code, and Enjoy research! Have fun!
Lbq1221119@cnblogs, first post at http://sscli.cnblogs.com
11/11/2008 9:42 PM
posted on 2008-11-12 18:48 lbq1221119 閱讀(3622) 評論(5) 收藏 舉報
浙公網安備 33010602011771號