前些天,发布了一个能够在Visual Studio2005查看sscli源代码的项目文件。不过,在VS2008中编译sscli,会出现一大堆错误。这里,有幸在Jeremy Kuhne's Blog上面找到了一篇文章来解决这个问题。
原文链接可以点这里。这里,时间原因就不翻译过来了,希望对sscli团队中研究这个的同志们有帮助,特别希望“装配脑袋”能看到这篇文章。
The currently available SSCLI 2.0 (Rotor) does not build successfully with Visual Studio 2008. I've managed to make it build and I thought I'd share my changes. Be very aware:
- I haven't done anything resembling thorough testing on these changes
- I made the changes so that it would build for me on my 32bit Vista machine
- I avoided changing source files, and focused on build files
- The warnings I disabled are pretty tame, see #3
- I tried to keep the changes to a minimum
- I know next to nothing about NMAKE
- I have no idea about any MS plans regarding SSCLI and VS2008
- This is does not constitute official support for building SSCLI in VS2008
/sscli20/mswin32.startup.pl
- change the if block that begins at line 41:
if (my $msvcdir = Get("MSVCDir")) {
# These are the INCLUDE paths used during the primary bootstrap.
my $winsdkdir = Get("ROTOR_WINSDKDIR");
Set("SDK_INC_PATH_BOOT", catdir ($winsdkdir, "include"));
Set("CRT_INC_PATH_BOOT", catdir ($msvcdir, "Include"));
Set("SDK_LIB_PATH", catdir ($winsdkdir, "lib"));
Set("CRT_LIB_PATH", catdir ($msvcdir, "lib"));
Set("VC_BIN_PATH", catdir ($msvcdir, "bin"));
}
/sscli20/win.env.bat
- change %VS80COMNTOOLS% on line 37 to %VS90COMNTOOLS%
- 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%
/sscli20/clr/src/classlibnative/nls/wks/sources; /sscli20/clr/src/debug/daccess/wks/sources; /sscli20/clr/src/vm/dacwks/sources; /sscli/clr/src/classlibnative/float/wks/sources; /sscli/clr/src/dlls/mscordac/wks/sources; /sscli/clr/src/vm/wks1/sources; /sscli/clr/src/vm/wks2/sources; /sscli/clr/src/vm/wks3/sources; /sscli/clr/src/vm/wks4/sources
- Kill line 16 (MSC_WARNING_LEVEL =-Wp64)
/sscli/clr/src/classlibnative/float/sources.inc
- Kill line 21 (COMPILER_WARNINGS =/W4)
/sscli20/clr/src/toolbox/sos/strike/sources
- Kill line 18 (MSC_WARNING_LEVEL =/W4)
/env/bin/devdiv.def
- Change line 334 to SUBSYSTEM_WINVER = ,5.00
- Change line 338 to SUBSYSTEM_CONVER = ,5.00
/pal/inc/vs9.h (NEW FILE)
// Patch up the conflicting defines to allow building with VS9
#undef MAKEWORD
#undef MAKELONG
#undef LOWORD
#undef HIWORD
#undef LOBYTE
#undef HIBYTE
#undef IPPROTO_IP
#undef IPPROTO_ICMP
#undef IPPROTO_IGMP
#undef IPPROTO_GGP
#undef IPPROTO_TCP
#undef IPPROTO_PUP
#undef IPPROTO_UDP
#undef IPPROTO_IDP
#undef IPPROTO_ND
#undef IPPROTO_RAW
#undef INADDR_ANY
#undef INADDR_BROADCAST
#undef INADDR_NONE
#pragma warning (disable :4985)
#define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
#define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
#ifdef _WIN64
#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
#else
#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
#endif
/sscli20/pal/win32/win32pal.h
- Add #include <Vs9.h> after line 1272 (before the windows includes)
/sscli20/tools/binplace/sources; /sscli/clr/src/tools/ildbdump/sources
- Change line 27 SUBSYSTEM_VERSION=4.00 to SUBSYSTEM_VERSION=5.00
/sscli20/tools/resourcecompiler/sources
- Change line 31 SUBSYSTEM_VERSION=4.00 to SUBSYSTEM_VERSION=5.00
/sscli20/tools/cppmunge/sources
- Change line 24 SUBSYSTEM_VERSION=4.00 to SUBSYSTEM_VERSION=5.00
/sscli20/tools/build/sources
- Change line 48 SUBSYSTEM_VERSION=4.00 to SUBSYSTEM_VERSION=5.00
/sscli20/pal/win32/make.cmd
- Kill the if not "%ROTOR_TOOLSET_VERSION%" block from line 43-46
/sscli20/clr/src/vm/sources.inc
- Add -wd4800 to the end of line 22
- Delete lines 23-25
/ssclie20/clr/src/classlibnative/nls/sources.inc
- Add -wd4800 to the end of line 20
/sscli20/csharp/sccomp/sources.inc
- Kill lines 52-54 (USER_C_FLAGS)
/sscli20/pal/win32/rotor_pal.src
- Replace line 57 (#if _MSC_VER == 1400) with:
#if _MSC_VER == 1500
#define _MSVCRT MSVCR90D
#elif _MSC_VER == 1400
-
b. Replace line 67 ( #if _MSC_VER == 1400) with:
#if _MSC_VER == 1500
#define _MSVCRT MSVCR90
#elif _MSC_VER == 1400
Well there you have it. Hopefully I didn't miss any of my changes or make too many typos. I ran through these instructions on a clean install of SSCLI and was able to successfully build per the docs and compile and run HelloWorld.