<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0">

<channel>
	<title>小李贼</title>
	
	<link>http://dipplum.com</link>
	<description>Be  the change you wanna see in the world</description>
	<lastBuildDate>Wed, 10 Mar 2010 13:30:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/cn/</creativeCommons:license>		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dipplum" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="dipplum" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Python调用搜狗云输入法的小例子</title>
		<link>http://dipplum.com/2010/01/22/sogou-cloud-ime-python/</link>
		<comments>http://dipplum.com/2010/01/22/sogou-cloud-ime-python/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 17:52:20 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[中文化]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ime]]></category>
		<category><![CDATA[pinyin]]></category>
		<category><![CDATA[sogou]]></category>

		<guid isPermaLink="false">http://dipplum.com/2010/01/22/sogou-cloud-ime-python/</guid>
		<description><![CDATA[写了个Python的小例子，调用搜狗云输入法获取汉字。感谢xzap在搜狗论坛发布的bash脚本，但觉得bash还是略微晦涩了点，用python说明搜狗云输入法的API更加清晰一点。

#!/usr/bin/python                   ... ]]></description>
			<content:encoded><![CDATA[<p>写了个Python的小例子，调用搜狗云输入法获取汉字。感谢xzap在搜狗论坛发布的<a href="http://pinyin.sogou.com/bbs/redirect.php?tid=140527&amp;goto=lastpost" target="_blank">bash脚本</a>，但觉得bash还是略微晦涩了点，用python说明搜狗云输入法的API更加清晰一点。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python                                                                                                                                           </span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">urllib</span> <span style="color: #ff7700;font-weight:bold;">import</span> urlopen
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">cgi</span> <span style="color: #ff7700;font-weight:bold;">import</span> parse_qs
&nbsp;
url = <span style="color: #483d8b;">'http://web.pinyin.sogou.com/web_ime/get_ajax/%s.key'</span>
&nbsp;
py = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'input pinyin: '</span><span style="color: black;">&#41;</span>
res = urlopen<span style="color: black;">&#40;</span>url <span style="color: #66cc66;">%</span> py<span style="color: black;">&#41;</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
dic = parse_qs<span style="color: black;">&#40;</span>res<span style="color: black;">&#41;</span>
lst = <span style="color: #008000;">eval</span><span style="color: black;">&#40;</span>dic<span style="color: black;">&#91;</span><span style="color: #483d8b;">'ime_query_res'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span> '</span><span style="color: black;">&#41;</span>
words = <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\x</span>ef<span style="color: #000099; font-weight: bold;">\x</span>bc<span style="color: #000099; font-weight: bold;">\x</span>9a'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, lst<span style="color: black;">&#41;</span>
counts = <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\x</span>ef<span style="color: #000099; font-weight: bold;">\x</span>bc<span style="color: #000099; font-weight: bold;">\x</span>9a'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, lst<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>words<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> words<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span>, counts<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span>
&nbsp;
exit</pre></div></div>

<p>运行该脚本的输出结果如下，每行前面是候选词/句，后面是该候选词/句消耗的英文单词个数：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>sogou.py
input pinyin: nihaosgysrf
你好搜狗云输入法 <span style="color: #000000;">11</span>
你好是 <span style="color: #000000;">6</span>
倪豪士 <span style="color: #000000;">6</span>
你好 <span style="color: #000000;">5</span>
拟好 <span style="color: #000000;">5</span>
倪浩 <span style="color: #000000;">5</span>
泥蒿 <span style="color: #000000;">5</span>
倪昊 <span style="color: #000000;">5</span>
倪皓 <span style="color: #000000;">5</span>
匿号 <span style="color: #000000;">5</span>
你 <span style="color: #000000;">2</span>
拟 <span style="color: #000000;">2</span>
呢 <span style="color: #000000;">2</span>
尼 <span style="color: #000000;">2</span>
泥 <span style="color: #000000;">2</span>
逆 <span style="color: #000000;">2</span>
妮 <span style="color: #000000;">2</span>
腻 <span style="color: #000000;">2</span>
倪 <span style="color: #000000;">2</span>
伱 <span style="color: #000000;">2</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2010/01/22/sogou-cloud-ime-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seccomp和系统调用过滤</title>
		<link>http://dipplum.com/2009/12/08/seccomp-syscall-filter/</link>
		<comments>http://dipplum.com/2009/12/08/seccomp-syscall-filter/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 02:13:43 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[seccomp]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/12/08/seccomp-syscall-filter/</guid>
		<description><![CDATA[Seccomp v1
Seccomp是2005年Andrea Arcangeli在Linux内核加的一个功能，为了给*Grid计算中的应用*提供sandbox模型。运行在Seccomp模式下的进程，只能执行下面几个系统调用：    &#160;&#160;&#160; read(), write(), exit... ]]></description>
			<content:encoded><![CDATA[<h4>Seccomp v1</h4>
<p>Seccomp是2005年Andrea Arcangeli在Linux内核加的一个功能，为了给*Grid计算中的应用*提供sandbox模型。运行在Seccomp模式下的进程，只能执行下面几个系统调用：    <br />&#160;&#160;&#160; read(), write(), exit(), sigreturn() </p>
<p>  <span id="more-461"></span>
<p>通过Seccomp沙箱，和4个api的限制，保证进程不会影响到其他进程。</p>
<h4>Seccomp v2</h4>
<p>2009年的时候，Ingo Molnar扩展了Seccomp的实现，让其支持更加全面的系统调用过滤(syscall filtering)的功能。Google Chrome Browser好像用的沙箱模型就是类似Seccomp的系统调用过滤。</p>
<p>Filter的规则是一个数组，每个元素包括两个字段，分别是系统调用名和过滤规则： </p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;sys_read&quot;</span><span style="color: #339933;">,</span>            <span style="color: #ff0000;">&quot;fd == 0&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;sys_write&quot;</span><span style="color: #339933;">,</span>        <span style="color: #ff0000;">&quot;fd == 1&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;sys_sigreturn&quot;</span><span style="color: #339933;">,</span>        <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;sys_gettimeofday&quot;</span><span style="color: #339933;">,</span>        <span style="color: #ff0000;">&quot;tz == NULL&quot;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>上面的第一条规则要求进程只能以fd = 0这个参数，调用sys_read。&#160; </p>
<h4>参考资料</h4>
<p>[1] Seccomp Wiki <a href="http://en.wikipedia.org/wiki/Seccomp">http://en.wikipedia.org/wiki/Seccomp</a> </p>
<p>[2] Seccomp and sandboxing <a href="http://lwn.net/Articles/332974/">http://lwn.net/Articles/332974/</a> </p>
<p>[3] seccomp: Add bitmask of allowed system calls <a href="http://lwn.net/Articles/332987/">http://lwn.net/Articles/332987/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/12/08/seccomp-syscall-filter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visual C++编译环境免安装命令行版</title>
		<link>http://dipplum.com/2009/11/13/visualc-compiler-portable/</link>
		<comments>http://dipplum.com/2009/11/13/visualc-compiler-portable/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 12:05:12 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[scons]]></category>
		<category><![CDATA[side-by-side]]></category>
		<category><![CDATA[visualc]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/13/visual-c%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83%e5%85%8d%e5%ae%89%e8%a3%85%e5%91%bd%e4%bb%a4%e8%a1%8c%e7%89%88/</guid>
		<description><![CDATA[VC的IDE开发环境很好，但太大了，经常是2005/2008/2010装一大堆，占用几十G的空间。用惯了Linux的命令行方式，觉得小巧精致。于是想把VC的基本命令提取出来，也做一个绿色版本。
保留基本的编... ]]></description>
			<content:encoded><![CDATA[<p>VC的IDE开发环境很好，但太大了，经常是2005/2008/2010装一大堆，占用几十G的空间。用惯了Linux的命令行方式，觉得小巧精致。于是想把VC的基本命令提取出来，也做一个绿色版本。</p>
<p>保留基本的编译命令，cl、lib、link、ml之类的。编译工程只能用nmake了。vcproj工程文件怎么办？用scons重写一个吧。(其实命令行也有个vcbuild)。</p>
<p>制作绿色版之前，首先要安装一个VC，再把其中用到的文件提取出来。或者直接快进到后面找下载链接。</p>
<h4></h4>
<p>  <span id="more-448"></span><br />
<h4>Visual C++ 2008制作要领</h4>
<p>VC 2008的最大问题是Visual Studio采用Side-by-Side方式发布，不能简单的把依赖的DLL着全就行了。</p>
<p>1. 复制C:\Program Files\Microsoft Visual Studio&#160; 9.0\VC\bin及其子目录1033，到新的vc9\bin目录</p>
<p>2. 在复制VC目录下的lib和include目录，到新的vc9目录下</p>
<p>3. 复制C:\Program Files\Microsoft Visual Studio 2008\Common7\IDE目录下的：msobj80.dll，mspdb80.dll, mspdbcore.dll, mspdbsrv.exe到vc9\bin</p>
<p>4. 在vc\bin生成manifest文件，名为Micrisoft.VC90.CRT.manifest，内容如下</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assembly</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:asm.v1&quot;</span> <span style="color: #000066;">manifestversion</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;noinheritable<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/noinheritable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblyidentity</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Microsoft.VC90.CRT&quot;</span> <span style="color: #000066;">publickeytoken</span>=<span style="color: #ff0000;">&quot;1fc8b3b9a1e18e3b&quot;</span> <span style="color: #000066;">processorarchitecture</span>=<span style="color: #ff0000;">&quot;x86&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;9.0.21022.8&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;win32&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/assemblyidentity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;msvcr90.dll&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;msvcp90.dll&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/assembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>5. 找到Windows\WinSxS目录下的x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_&#8230;目录，复制其中的msvcr90.dll和msvcp90.dll到bin目录</p>
<h4>Visual C++ 2010制作要领</h4>
<p>VC 2010还在Beta阶段，不过据说已经决定不用SxS，直接用DLL发布了，所以制作简单点。</p>
<p>1-3和2008类似，复制bin, include, lib，复制Common7\IDE目录下的几个dll和exe</p>
<p>4. 到Windows\System32目录下找msvcr100.dll, msvcp100.dll，复制到bin</p>
<h4>Windows SDK</h4>
<p>VC的lib和include里面不带Windows的头文件和库，所以还需要把Windows SDK摘取出来。Windows SDK在安装的时候一般装在C:\Program Files\Microsoft SDKs\Windows\XX目录下，同样把其中的bin, lib, include目录复制出来，到一个新目录，比如win6sdk。</p>
<h4></h4>
<h4>环境设置</h4>
<p>影响C编译器的环境变量就三个，INCLUDE、LIB和PATH。设置好就可以编译了。假定上面我把VC 2008和Windows SDK分别复制到了vc9和win6sdk目录下，在与这两个目录的上级目录中，创建一个BAT脚本，假设叫vc9.bat，包含下面内容：</p>

<div class="wp_syntax"><div class="code"><pre class="bat" style="font-family:monospace;">@echo off
echo Setting environment Visual C++ 2010
&nbsp;
set VCINSTALLDIR=%~dp0vc9
set WindowsSdkDir=%~dp0win6sdk
&nbsp;
set INCLUDE=%WindowsSdkDir%\include;%VCINSTALLDIR%\include
set LIB=%WindowsSdkDir%\lib;%VCINSTALLDIR%\lib
set PATH=%FrameworkDir%\%FrameworkVersion%;%WindowsSdkDir%\bin;%VCINSTALLDIR%\bin;%PATH%</pre></div></div>

<p>再创建一个BAT脚本，叫start-vc9.bat，包含下面一行：</p>

<div class="wp_syntax"><div class="code"><pre class="bat" style="font-family:monospace;">start cmd /K %~dp0vc10.bat</pre></div></div>

<p>在Windows资源管理器中双击start-vc9.bat就可以配置好环境变量，进入VC 2008的编译环境了。</p>
<h4>下载</h4>
<p>1. vc10.rar 21M 2010的命令行工具和include/lib打包 <a href="http://www.uploadground.com/files/EPIKIHXP/vc10.rar" target="_blank">下载</a></p>
<p>需要和3解压到到一起用。双击start-vc10.bat打开一个命令行窗口，就可以用cl, nmake, link等命令了。VC需要的基本环境变量会自动设置。</p>
<p>2. vc9.rar 15M 2008的命令行工具和include/lib打包 <a href="http://www.uploadground.com/files/PY34KVNT/vc9.rar" target="_blank">下载</a></p>
<p>需要和3解压到一起用。双击start-vc9.bat打开命令行窗口，VC需要的环境变量会自动设置。</p>
<p>3. win7.rar 16M Windows 7.0 SDK的include/lib打包 <a href="http://www.uploadground.com/files/1FX250AB/win7.rar" target="_blank">下载</a></p>
<p>注意：命令行编译环境没有包含Debug版的CRT，所有的MFC、ATL的DLL。所以可能存在编译好的程序缺少DLL不能运行的问题。对于2008，可以下载一个VC相关SxS打包。缺DLL就到里面找(参见我的<a href="/2009/11/09/side-by-side-assembly/" target="_blank">Side-by-Side笔记</a>)。对于2010，由于已经废弃了SxS的发布方式，可以直接到网上下载缺的DLL。</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/13/visualc-compiler-portable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>stratagus最新Windows版</title>
		<link>http://dipplum.com/2009/11/13/stratagus-svn-windows/</link>
		<comments>http://dipplum.com/2009/11/13/stratagus-svn-windows/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 09:12:23 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[stratagus]]></category>
		<category><![CDATA[visualc]]></category>
		<category><![CDATA[warcraft]]></category>
		<category><![CDATA[wargus]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/13/stratagus-svn-windows/</guid>
		<description><![CDATA[简介
stratagus的前身是freecraft。freecraft重写了Blizzard公司的经典游戏Warcraft II的RTS游戏引擎。后因版权问题改名。freecraft改名后分成了几个部分，stratagus项目承接了其游戏引擎的部分，wargus在strata... ]]></description>
			<content:encoded><![CDATA[<h4>简介</h4>
<p><a href="http://stratagus.sourceforge.net/" target="_blank">stratagus</a>的前身是freecraft。freecraft重写了Blizzard公司的经典游戏<a href="http://us.blizzard.com/en-us/games/legacy/" target="_blank">Warcraft II</a>的RTS游戏引擎。后因<a href="http://en.wikipedia.org/wiki/Stratagus" target="_blank">版权问题改名</a>。freecraft改名后分成了几个部分，stratagus项目承接了其游戏引擎的部分，wargus在stratagus引擎上进行二次开发，几乎完美重现了Warcaft II的功能。下面是Wargus/Stratagus的效果：</p>
<p><a href="http://dipplum.com/wp-content/uploads/2009/11/stratagus1.png" rel="lightbox[441]"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="stratagus1" border="0" alt="stratagus1" src="http://dipplum.com/wp-content/uploads/2009/11/stratagus1_thumb.png" width="244" height="184" /></a> <a href="http://dipplum.com/wp-content/uploads/2009/11/stratagus2.png" rel="lightbox[441]"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="stratagus2" border="0" alt="stratagus2" src="http://dipplum.com/wp-content/uploads/2009/11/stratagus2_thumb.png" width="244" height="184" /></a> <a href="http://dipplum.com/wp-content/uploads/2009/11/stratagus3.png" rel="lightbox[441]"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="stratagus3" border="0" alt="stratagus3" src="http://dipplum.com/wp-content/uploads/2009/11/stratagus3_thumb.png" width="244" height="184" /></a> <a href="http://dipplum.com/wp-content/uploads/2009/11/stratagus4.png" rel="lightbox[441]"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="stratagus4" border="0" alt="stratagus4" src="http://dipplum.com/wp-content/uploads/2009/11/stratagus4_thumb.png" width="244" height="184" /></a> </p>
</p>
</p>
<h4>下载说明</h4>
<p> <span id="more-441"></span>
<p>Statagus已经在2年前停止开发了，开发人员用同样的引擎转去开发别的游戏了。最后一个版本是2.2.4。但SVN库里还陆续有大的变动，开发人员好像是会不时的merge一些新的功能过来。</p>
<p>我编译的是最新的Stratagus SVN版本r8003，截图上显示的是2.2.5，这个版本有bug，打上了好几处补丁。编译环境是Visual C++ 2008。</p>
<p>1. stratagus-r8003引擎本地下载，需要再下载2 Note: There is a file embedded within this post, please visit this post to download the file.</p>
<p>2. 支持stratagus-r8003的Wargus游戏数据 <a href="http://is.gd/4U3om">网盘下载</a></p>
<p>3. 用VMWare ThinApp打包的单可执行程序，单独可运行 <a href="http://is.gd/4RO0k" target="_blank">网盘下载</a></p>
<h4>开发包下载</h4>
<p>如果对源码感兴趣，想自己编译的，可以下载我的Patch和编译环境打包</p>
<p>1. r8003的patch文件，自己checkout的stratagus svn r8003目录，解压后覆盖之 Note: There is a file embedded within this post, please visit this post to download the file.</p>
<p>2. stratagus引用的外部lib和头文件打包，用Visual C++ 2008编译，解压后放在stratagus源码上级目录 Note: There is a file embedded within this post, please visit this post to download the file.</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/13/stratagus-svn-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最近用scons的收获</title>
		<link>http://dipplum.com/2009/11/13/scons-tips/</link>
		<comments>http://dipplum.com/2009/11/13/scons-tips/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 07:59:28 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scons]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/13/scons-tips/</guid>
		<description><![CDATA[背景
Windows平台上的编译工程工具很多，Visual C++ 6的dsp文件，2003以后用的vcproj，以及最近2010支持的用msbuild编译的vcxproj，加上古老的nmake，cygwin、msys移植的make，等等很多。
make的问题是扩展性... ]]></description>
			<content:encoded><![CDATA[<h4>背景</h4>
<p>Windows平台上的编译工程工具很多，Visual C++ 6的dsp文件，2003以后用的vcproj，以及最近2010支持的用msbuild编译的vcxproj，加上古老的nmake，cygwin、msys移植的make，等等很多。</p>
<p>make的问题是扩展性比较差，尤其是在Windows平台上，nmake的功能更弱，导致写一个工程文件很费劲，管理多个工程有大量的重复工作要做。make最大的问题是不能automake那种简洁的工程写法（automake同样存在扩展问题，m4语言不懂）.</p>
<p>最新的msbuild 4.0试用了一下，感觉不是很好，很费劲。因为最近迷恋上了命令行，一直不愿意安装完整的Visual Studio 2010 Beta 2，直接把2010的命令行拷贝出来用cl.exe之类的。想只装.Net Framework 4.0就试试msbuild，发现不行，把2010里的msbuild相关资源拷贝出来也不行。而且用XML手写工程文件很麻烦。</p>
<p>猛然想起之前听说过，鼎鼎大名，但之前简单了解后放弃了的scons。再次使用之后，才发现scons的妙处。</p>
<h4></h4>
<p> <span id="more-432"></span><br />
<h4>简介Scons</h4>
<p>Scons首页赫然是Eric Raymond的推荐，很是唬人的样子。Scons是python写的，这不重要。Scons脚本用语言是python，这是Scons最吸引人的地方。用python写工程文件无疑对我这种熟悉python的人有很大的吸引力。</p>
<p>实际上，Scons最大的优势，就是描述语言本身沿用python。这种设计极大的提升的Scons的扩展能力。Scons本身功能是否强大不重要，对于熟悉python的人来说，扩展Scons达到他的要求，变得比以前简单的多。下面是我用Scons写的一个zlib的工程文件，其中WinLib和WinDLL是我自己扩展的在Windows平台上编译静态库和动态库的方法（cl的宏定义和link的参数有所不同）。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">target = <span style="color: #483d8b;">'libz'</span>
defs = <span style="color: #483d8b;">'ASMV ASMINF'</span>
incs = <span style="color: #483d8b;">'.'</span>
&nbsp;
Import<span style="color: black;">&#40;</span><span style="color: #483d8b;">'env'</span><span style="color: black;">&#41;</span>
lib_src = Split<span style="color: black;">&#40;</span><span style="color: #483d8b;">'contrib/masmx86/inffas32.asm contrib/masmx86/gvmat32.asm adler32.c compress.c crc32.c deflate.c gzio.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c contrib/masmx86/gvmat32c.c'</span><span style="color: black;">&#41;</span>
lib_src += env.<span style="color: black;">RES</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'win32/zlib1.rc'</span><span style="color: black;">&#41;</span>
dll_src = lib_src + Split<span style="color: black;">&#40;</span><span style="color: #483d8b;">'win32/zlib.def'</span><span style="color: black;">&#41;</span>
&nbsp;
Import<span style="color: black;">&#40;</span><span style="color: #483d8b;">'WinLib WinDLL'</span><span style="color: black;">&#41;</span>
lib = WinLib<span style="color: black;">&#40;</span>target, lib_src, CPPDEFINES=defs, CPPPATH=incs<span style="color: black;">&#41;</span>
dll = WinDLL<span style="color: black;">&#40;</span>target, dll_src, CPPDEFINES=defs, CPPPATH=incs<span style="color: black;">&#41;</span>
&nbsp;
Alias<span style="color: black;">&#40;</span>target, <span style="color: black;">&#91;</span>lib, dll<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>实际上Scons本身的功能比较有限，为了写成这个简洁的模式，还费了不少劲。</p>
<h4>Scons的特点</h4>
<p>简单列举下最近有体会的Scons的特点，权当备忘录了。</p>
<p>1. Variables的设计很好。</p>
<p>通过Variables可以扩展scons支持的命令行参数，限制参数种类（Bool，枚举，多选），可以把上次的参数保存到文件，下次编译不需要命令行输入过多的参数。下面摘下我的Variable定义：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">vars</span> = Variables<span style="color: black;">&#40;</span><span style="color: #483d8b;">'options.ini'</span><span style="color: black;">&#41;</span>
<span style="color: #008000;">vars</span>.<span style="color: black;">AddVariables</span><span style="color: black;">&#40;</span>
    BoolVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'verbose'</span>, <span style="color: #483d8b;">'Show verbose messages'</span>, <span style="color: #483d8b;">'no'</span><span style="color: black;">&#41;</span>,
    BoolVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'unicode'</span>, <span style="color: #483d8b;">'Use unicode API'</span>, <span style="color: #483d8b;">'yes'</span><span style="color: black;">&#41;</span>,
    BoolVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'debug'</span>, <span style="color: #483d8b;">'Generate debug code'</span>, <span style="color: #483d8b;">'no'</span><span style="color: black;">&#41;</span>,
    EnumVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'warn'</span>, <span style="color: #483d8b;">'Show warning level'</span>, <span style="color: #483d8b;">'no'</span>, <span style="color: black;">&#91;</span><span style="color: #483d8b;">'no'</span>, <span style="color: #483d8b;">'low'</span>, <span style="color: #483d8b;">'all'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
    EnumVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'optimize'</span>, <span style="color: #483d8b;">'Set optimization mode'</span>, <span style="color: #483d8b;">'normal'</span>, <span style="color: black;">&#91;</span><span style="color: #483d8b;">'normal'</span>, <span style="color: #483d8b;">'max'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
    PathVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'repos_root'</span>, <span style="color: #483d8b;">'Path to root of source repository'</span>, <span style="color: #483d8b;">'..'</span><span style="color: black;">&#41;</span>,
    PathVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'build_root'</span>, <span style="color: #483d8b;">'Path to root of build directory'</span>, <span style="color: #483d8b;">'build'</span>,
        PathVariable.<span style="color: black;">PathIsDirCreate</span><span style="color: black;">&#41;</span>,
    PathVariable<span style="color: black;">&#40;</span><span style="color: #483d8b;">'output_root'</span>, <span style="color: #483d8b;">'Path to output directory'</span>, <span style="color: #483d8b;">'.'</span>,
        PathVariable.<span style="color: black;">PathIsDirCreate</span><span style="color: black;">&#41;</span>,
<span style="color: black;">&#41;</span>
env = Environment<span style="color: black;">&#40;</span>ENV = <span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span>, variables = <span style="color: #008000;">vars</span><span style="color: black;">&#41;</span></pre></div></div>

<p>2. Environment的设计也很好。</p>
<p>Environment可以保存全套的编译命令，参数配置，用Clone操作可以从一个基本编译环境作出很多变种，支持不同项目类型，不同配置的编译。Clone实在是太方便了。下面是前面提到的Windows平台下编译DLL和静态库、命令行程序的不同参数配置，用Clone操作可以在基本编译环境上，生成多个用于编译静态库、DLL等不同的编译环境，使用不同的参数编译。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">libEnv = env.<span style="color: black;">Clone</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
libEnv.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>CPPDEFINES = Split<span style="color: black;">&#40;</span><span style="color: #483d8b;">'_WINDOWS _WINDLL'</span><span style="color: black;">&#41;</span>, LINKFLAGS = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'/SUBSYSTEM:WINDOWS'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
dllEnv = env.<span style="color: black;">Clone</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
dllEnv.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>CPPDEFINES = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'_WINDOWS'</span><span style="color: black;">&#93;</span>, LINKFLAGS = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'/SUBSYSTEM:WINDOWS'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
conEnv = env.<span style="color: black;">Clone</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
conEnv.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>CPPDEFINES = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'_CONSOLE'</span><span style="color: black;">&#93;</span>, LINKFLAGS = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'/SUBSYSTEM:CONSOLE'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>题外话，关于Windows下编译不同工程的参数，<a href="http://binglongx.spaces.live.com/blog/cns!142CBF6D49079DE8!276.entry" target="_blank">这篇文章</a>总结的很全。</p>
<p>3. Builder的设计问题。</p>
<p>Scons可以用env.Library(&#8216;liba&#8217;, &#8216;a.c&#8217;)的方法用环境的定义编译静态库，或者用Program定义可执行程序。并且支持输入和环境定义不同的参数，如</p>
<p>env.Library(&#8216;liba&#8217;, &#8216;a.c&#8217;, CPPDEFINES = ['NEWMACRO'], CCFLAGS=['/Ox'])。</p>
<p>不过，很可惜，Builder默认是覆盖环境中现有参数，而不是追加。所以，要用多个编译参数稍有不同的程序和库编译只能用Clone后Append。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">tempEnv = libEnv.<span style="color: black;">Clone</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
tempEnv.<span style="color: black;">Append</span><span style="color: black;">&#40;</span>CPPDEFINES = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'NEWMACRO'</span><span style="color: black;">&#93;</span>, CCFLAGS=<span style="color: black;">&#91;</span><span style="color: #483d8b;">'/Ox'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
tempEnv.<span style="color: black;">Library</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'liba'</span>, <span style="color: #483d8b;">'a.c'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>或许我要求太高，不过这样写看起来实在太傻了。实际使用中，不同的程序用的编译参数就没有完全一样的，尤其是Include目录、宏定义、库路径、库这四个参数肯定有或多或少的不一样。不能追加的话，就只能Clone出很多个Env，甚至是一个Program或Library一个Env，这就失去了Env封装编译环境的通用意义了。</p>
<p>4. Sconscript与源码的位置问题</p>
<p>Scons设计时更多是支持将Sconscript放在源码同一目录下，甚至每个源码目录一个Soncscript。如果不习惯或者不能用这种方式，比如为别的项目写工程文件，遇到一些困扰。</p>
<p>Scons好在有类似make的VPATH功能，叫Repository，用着还行。</p>
<p>5. 源码和编译目录分开的问题</p>
<p>这个问题和上面类似，但更严重。Scons支持用VariantDir设定与源码目录不同的编译目录，但必须所有的文件都用编译目录的路径，如下</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">VariantDir<span style="color: black;">&#40;</span><span style="color: #483d8b;">'build_dir'</span>, <span style="color: #483d8b;">'src_dir'</span><span style="color: black;">&#41;</span>
Program<span style="color: black;">&#40;</span><span style="color: #483d8b;">'build_dir/prog'</span>, <span style="color: #483d8b;">'build_src/main.c'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>这就很傻了，明明源码在src_dir目录，一定要写成build_src。不这么写也行，那就写两个Sconcript文件，一个引用另外一个</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#SConscriptA</span>
Program<span style="color: black;">&#40;</span><span style="color: #483d8b;">'prog'</span>, <span style="color: #483d8b;">'src/main.c'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#SConscriptB</span>
SConscript<span style="color: black;">&#40;</span><span style="color: #483d8b;">'SconscriptA'</span>, variant_dir=<span style="color: #483d8b;">'build'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>要用好VariantDir，就必须写多个脚本。尤其是要支持编译同一程序的多个版本，还只能用两个脚本。SconscriptB可以按如下方式写，就能编译两个版本的prog，分别在debug和release目录下。用一个Sconscript完成同样功能实在是很费劲的。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">SConscript<span style="color: black;">&#40;</span><span style="color: #483d8b;">'SconscriptA'</span>, variant_dir=<span style="color: #483d8b;">'debug'</span><span style="color: black;">&#41;</span>
SConscript<span style="color: black;">&#40;</span><span style="color: #483d8b;">'SconscriptA'</span>, variant_dir=<span style="color: #483d8b;">'release'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>6. 同一个源码编译多份的问题</p>
<p>这个问题和上面类似，但不同。例如编译静态库和动态库都用一批源码，但编译参数不一样，Scons就会报错。但这个问题用variant_dir解决不方便。如下例：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">Program<span style="color: black;">&#40;</span><span style="color: #483d8b;">'hello1'</span>, <span style="color: #483d8b;">'hello.c'</span>, CCFLAGS=<span style="color: black;">&#91;</span><span style="color: #483d8b;">'-Od'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
Program<span style="color: black;">&#40;</span><span style="color: #483d8b;">'hello2'</span>, <span style="color: #483d8b;">'hello.c'</span>, CCFLAGS=<span style="color: black;">&#91;</span><span style="color: #483d8b;">'-Ox'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Scons报错如下：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">scons: <span style="color: #000000; font-weight: bold;">***</span> Two environments with different actions were specified <span style="color: #000000; font-weight: bold;">for</span> the same target:</pre></div></div>

<p>经过我多方论证，发现这个问题目前看来最佳、最简单的解决方法是给OBJ文件设置前缀。</p>
<pre>Program('hello1', 'hello.c', OBJPREFIX='dbg-', CCFLAGS=['-Od'])
Program('hello2', 'hello.c', OBJPREFIX='opt-', CCFLAGS=['-Ox'])</pre>
<p>7. 简化编译输出的问题</p>
<p>Scons支持自定义的编译输出。但有些命令不能替换，例如msvc工具集中的链接过程的输出。</p>
<p>暂时这么多吧&#8230;想到再补充。</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/13/scons-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual C++ 2009编译libmikmod</title>
		<link>http://dipplum.com/2009/11/10/visualc-compile-libmikmod/</link>
		<comments>http://dipplum.com/2009/11/10/visualc-compile-libmikmod/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 03:13:18 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[乱七八糟]]></category>
		<category><![CDATA[mikmod]]></category>
		<category><![CDATA[stratagus]]></category>
		<category><![CDATA[visualc]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/10/visual-c-2009%e7%bc%96%e8%af%91libmikmod/</guid>
		<description><![CDATA[1. 主页 http://mikmod.raphnet.net/
2. 最新版本 3.2.0-beta2，2004年2月发布
&#160;&#160;&#160; 下载 http://mikmod.raphnet.net/files/libmikmod-3.2.0-beta2.zip
3. 编译依赖
&#160;&#160;&#160; DirectX SDK中的头文件。最新的DirectX SDK ... ]]></description>
			<content:encoded><![CDATA[<p>1. 主页 <a href="http://mikmod.raphnet.net/">http://mikmod.raphnet.net/</a></p>
<p>2. 最新版本 3.2.0-beta2，2004年2月发布</p>
<p>&#160;&#160;&#160; 下载 <a href="http://mikmod.raphnet.net/files/libmikmod-3.2.0-beta2.zip">http://mikmod.raphnet.net/files/libmikmod-3.2.0-beta2.zip</a></p>
<p>3. 编译依赖</p>
<p>&#160;&#160;&#160; DirectX SDK中的头文件。最新的DirectX SDK 2009 Auguest可以从微软（<a href="http://is.gd/4Q3Mo）">http://is.gd/4Q3Mo）</a>下载。或者只下载其中include目录和lib目录打包（<a href="http://is.gd/4Q416">http://is.gd/4Q416</a>）。</p>
<p>4. 编译方法</p>
<p>&#160;&#160;&#160; 解压后，从Visual Studio 2008的命令行提示符下进入win32目录，首先设置INCLUDE变量，然后编译。如果编译静态链接库，可以参见下例（把directx的目录修改成自己的）：</p>

<div class="wp_syntax"><div class="code"><pre class="batch" style="font-family:monospace;">cd win32
set INCLUDE=..\..\directxsdk-0908\include;%INCLUDE%
nmake -f makefile.static</pre></div></div>

</p>
<p><span id="more-425"></span></p>
<p>5. Bug</p>
<p>&#160;&#160;&#160; include\mikmod_internal.h文件中有bug，导致不能在Visual Studio 2008下编译，在该文件的include之后加入下面5行：</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#ifdef _mm_malloc</span>
<span style="color: #339933;">#undef _mm_malloc</span>
<span style="color: #339933;">#undef _mm_calloc</span>
<span style="color: #339933;">#undef _mm_free</span>
<span style="color: #339933;">#endif</span></pre></div></div>

<p>6. 其他注意事项</p>
<p>&#160;&#160;&#160; 1. 编译Multithreaded DLL版的静态库</p>
<p>&#160;&#160;&#160; 编译生成的静态库，为了更好的与其他库交互，最好是编译生成Multithreaded DLL版本，也就是编译时加/MD参数。由于libmikmod默认的头文件不支持编译静态库的同时，链接到MSVCRT的Muiltithreaded DLL。所以要做相应修改。</p>
<p>&#160;&#160;&#160; 2. 生成include\mikmod.h</p>
<p>&#160;&#160;&#160; 由于Windows系统没有configure过程，include目录下仅有一个mikmod.h.in，要把其中的版本号替换生成mikmod.h。 </p>
<p>&#160;&#160;&#160; 3. 静态库中缺少load_asy</p>
<p>&#160;&#160;&#160; 静态库中包含的目标文件好像不全，却load_asy，需要修改Makefile将其加进来。</p>
<p>7. 完整的patch</p>
<p>&#160;&#160;&#160; 下面是包含上述改动完整的patch。打上后把include\mikmod.in.h改名为include\mikmod.h即可。</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">diff -Naur libmikmod-3.2.0-beta2\include\mikmod.h.in libmikmod-3.2.0-beta2-<span style="">2</span>\include\mikmod.h.in
<span style="color: #888822;">--- libmikmod-3.2.0-beta2\include\mikmod.h.in	Wed Feb <span style="">18</span> 09:<span style="">10</span>:<span style="">40</span> 2004</span>
<span style="color: #888822;">+++ libmikmod-3.2.0-beta2-<span style="">2</span>\include\mikmod.h.in	Mon Apr <span style="">26</span> <span style="">18</span>:<span style="">33</span>:00 2004</span>
<span style="color: #440088;">@@ -<span style="">44</span>,<span style="">7</span> +<span style="">44</span>,<span style="">7</span> @@</span>
 #ifdef DLL_EXPORTS
 #define MIKMODAPI __declspec<span style="">&#40;</span>dllexport<span style="">&#41;</span>
 #else
<span style="color: #991111;">-#define MIKMODAPI __declspec<span style="">&#40;</span>dllimport<span style="">&#41;</span></span>
<span style="color: #00b000;">+#define MIKMODAPI</span>
 #endif
 #else
 #define MIKMODAPI
<span style="color: #440088;">@@ -<span style="">54</span>,<span style="">9</span> +<span style="">54</span>,<span style="">9</span> @@</span>
  *	========== Library version
  */
&nbsp;
<span style="color: #991111;">-#define LIBMIKMOD_VERSION_MAJOR @LIBMIKMOD_MAJOR_VERSION@L</span>
<span style="color: #991111;">-#define LIBMIKMOD_VERSION_MINOR @LIBMIKMOD_MINOR_VERSION@L</span>
<span style="color: #991111;">-#define LIBMIKMOD_REVISION      @LIBMIKMOD_MICRO_VERSION@L</span>
<span style="color: #00b000;">+#define LIBMIKMOD_VERSION_MAJOR 3L</span>
<span style="color: #00b000;">+#define LIBMIKMOD_VERSION_MINOR 2L</span>
<span style="color: #00b000;">+#define LIBMIKMOD_REVISION      0L</span>
&nbsp;
 #define LIBMIKMOD_VERSION \
 	<span style="">&#40;</span><span style="">&#40;</span>LIBMIKMOD_VERSION_MAJOR&amp;lt;&amp;lt;<span style="">16</span><span style="">&#41;</span>| \
<span style="color: #440088;">@@ -<span style="">83</span>,<span style="">7</span> +<span style="">83</span>,<span style="">7</span> @@</span>
 typedef char CHAR;
 #endif
&nbsp;
<span style="color: #991111;">-@DOES_NOT_HAVE_SIGNED@</span>
<span style="color: #00b000;">+</span>
&nbsp;
 #if defined<span style="">&#40;</span>__arch64__<span style="">&#41;</span> || defined<span style="">&#40;</span>__alpha<span style="">&#41;</span>
 /* <span style="">64</span> bit architectures */
diff -Naur libmikmod-3.2.0-beta2\include\mikmod_internals.h libmikmod-3.2.0-beta2-<span style="">2</span>\include\mikmod_internals.h
<span style="color: #888822;">--- libmikmod-3.2.0-beta2\include\mikmod_internals.h	Wed Feb <span style="">18</span> 08:<span style="">29</span>:<span style="">18</span> 2004</span>
<span style="color: #888822;">+++ libmikmod-3.2.0-beta2-<span style="">2</span>\include\mikmod_internals.h	Tue Nov <span style="">10</span> <span style="">10</span>:<span style="">47</span>:<span style="">10</span> 2009</span>
<span style="color: #440088;">@@ -<span style="">47</span>,<span style="">6</span> +<span style="">47</span>,<span style="">12</span> @@</span>
 #pragma warning<span style="">&#40;</span>disable:<span style="">4761</span><span style="">&#41;</span>
 #endif
&nbsp;
<span style="color: #00b000;">+#ifdef _mm_malloc</span>
<span style="color: #00b000;">+#undef _mm_malloc</span>
<span style="color: #00b000;">+#undef _mm_calloc</span>
<span style="color: #00b000;">+#undef _mm_free</span>
<span style="color: #00b000;">+#endif</span>
<span style="color: #00b000;">+</span>
 /*========== More type definitions */
&nbsp;
 /* SLONGLONG: 64bit, signed */
diff -Naur libmikmod-3.2.0-beta2\win32\Makefile.static libmikmod-3.2.0-beta2-<span style="">2</span>\win32\Makefile.static
<span style="color: #888822;">--- libmikmod-3.2.0-beta2\win32\Makefile.static	Wed Jan <span style="">21</span> <span style="">12</span>:<span style="">29</span>:<span style="">36</span> 2004</span>
<span style="color: #888822;">+++ libmikmod-3.2.0-beta2-<span style="">2</span>\win32\Makefile.static	Mon Nov 09 <span style="">15</span>:<span style="">28</span>:<span style="">39</span> 2009</span>
<span style="color: #440088;">@@ -<span style="">11</span>,<span style="">7</span> +<span style="">11</span>,<span style="">7</span> @@</span>
 # Your compiler here
 CC=cl
 # Compiler flags
<span style="color: #991111;">-CFLAGS=/nologo /O2 /MTd /Zi /Fm /c /DWIN32 /DDRV_DS /DDRV_WIN /DHAVE_FCNTL_H /DHAVE_MALLOC_H /DHAVE_LIMITS_H</span>
<span style="color: #00b000;">+CFLAGS=/nologo /O2 /MD /Zi /Fm /c /DWIN32 /DDRV_DS /DDRV_WIN /DHAVE_FCNTL_H /DHAVE_MALLOC_H /DHAVE_LIMITS_H</span>
 COMPILE=$<span style="">&#40;</span>CC<span style="">&#41;</span> $<span style="">&#40;</span>CFLAGS<span style="">&#41;</span> /I..\include /I.. /I..\win32
&nbsp;
 .SUFFIXES:
<span style="color: #440088;">@@ -<span style="">29</span>,<span style="">6</span> +<span style="">29</span>,<span style="">7</span> @@</span>
     load_669.o load_amf.o load_dsm.o load_far.o load_gdm.o load_it.o  \
     load_imf.o load_m15.o load_med.o load_mod.o load_mtm.o load_okt.o \
     load_s3m.o load_stm.o load_stx.o load_ult.o load_uni.o load_xm.o \
<span style="color: #00b000;">+    load_asy.o \</span>
     mmalloc.o mmerror.o mmio.o \
     mdriver.o mdreg.o mloader.o mlreg.o mlutil.o mplayer.o munitrk.o mwav.o \
     npertab.o sloader.o virtch.o virtch2.o virtch_common.o
<span style="color: #440088;">@@ -<span style="">106</span>,<span style="">6</span> +<span style="">107</span>,<span style="">9</span> @@</span>
 load_s3m.o:     ..\loaders\load_s3m.c \
 	                ..\win32\mikmod_build.h ..\include\mikmod_internals.h
 	$<span style="">&#40;</span>COMPILE<span style="">&#41;</span> /Fo$@ ..\loaders\load_s3m.c
<span style="color: #00b000;">+load_asy.o:     ..\loaders\load_asy.c \</span>
<span style="color: #00b000;">+	                ..\win32\mikmod_build.h ..\include\mikmod_internals.h</span>
<span style="color: #00b000;">+	$<span style="">&#40;</span>COMPILE<span style="">&#41;</span> /Fo$@ ..\loaders\load_asy.c</span>
 load_stm.o:     ..\loaders\load_stm.c \
 	                ..\win32\mikmod_build.h ..\include\mikmod_internals.h
 	$<span style="">&#40;</span>COMPILE<span style="">&#41;</span> /Fo$@ ..\loaders\load_stm.c
diff -Naur libmikmod-3.2.0-beta2\win32\mikmod_build.h libmikmod-3.2.0-beta2-<span style="">2</span>\win32\mikmod_build.h
<span style="color: #888822;">--- libmikmod-3.2.0-beta2\win32\mikmod_build.h	Thu Feb <span style="">19</span> 09:<span style="">15</span>:<span style="">22</span> 2004</span>
<span style="color: #888822;">+++ libmikmod-3.2.0-beta2-<span style="">2</span>\win32\mikmod_build.h	Mon Nov 09 <span style="">15</span>:<span style="">19</span>:<span style="">11</span> 2009</span>
<span style="color: #440088;">@@ -<span style="">44</span>,<span style="">7</span> +<span style="">44</span>,<span style="">7</span> @@</span>
 #ifdef DLL_EXPORTS
 #define MIKMODAPI __declspec<span style="">&#40;</span>dllexport<span style="">&#41;</span>
 #else
<span style="color: #991111;">-#define MIKMODAPI __declspec<span style="">&#40;</span>dllimport<span style="">&#41;</span></span>
<span style="color: #00b000;">+#define MIKMODAPI</span>
 #endif
 #else
 #define MIKMODAPI</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/10/visualc-compile-libmikmod/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Visual C++ 2008编译libpng</title>
		<link>http://dipplum.com/2009/11/09/visualc-compile-libpng/</link>
		<comments>http://dipplum.com/2009/11/09/visualc-compile-libpng/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 05:23:39 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[libpng]]></category>
		<category><![CDATA[visualc]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/09/visualc-compile-libpng/</guid>
		<description><![CDATA[1. 主页 http://www.libpng.org/pub/png/libpng.html
2. 最新稳定版本 1.2.40
&#160;&#160;&#160; 源码下载 http://download.sourceforge.net/libpng/lpng1240.zip
3. 编译依赖
&#160;&#160;&#160; 依赖zlib。要求名为zlib的目录位于和libpng... ]]></description>
			<content:encoded><![CDATA[<p>1. 主页 <a href="http://www.libpng.org/pub/png/libpng.html">http://www.libpng.org/pub/png/libpng.html</a></p>
<p>2. 最新稳定版本 1.2.40</p>
<p>&#160;&#160;&#160; 源码下载 <a href="http://download.sourceforge.net/libpng/lpng1240.zip">http://download.sourceforge.net/libpng/lpng1240.zip</a></p>
<p>3. 编译依赖</p>
<p>&#160;&#160;&#160; 依赖zlib。要求名为zlib的目录位于和libpng源码平级的目录下。libpng会自行编译zlib的源码，而zlib 1.2.3版本中的汇编代码在VC 2008下编译存在问题，参见<a href="http://dipplum.com/2009/11/08/visualc-compile-zlib/" target="_blank">zlib的编译说明</a>。</p>
<p>4. 编译方法</p>
<p>&#160;&#160;&#160; 打开源码中的projects\vc71\libpng.sln工程文件。编译DLL ASM Release和LIB ASM Release就可以了。会得到libpng.lib、libpng13.lib、libpng13.dll。</p>
<p>5. 注意</p>
<p>&#160;&#160;&#160; ligpng会编译自己的zlib1.dll和zlib.lib，不知道编译参数和zlib自己的工程文件是否一样，也不知道和zlib工程文件编译出的dll和lib会不会冲突。这个问题留待考察。</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/09/visualc-compile-libpng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Side-by-Side Assembly相关</title>
		<link>http://dipplum.com/2009/11/09/side-by-side-assembly/</link>
		<comments>http://dipplum.com/2009/11/09/side-by-side-assembly/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 04:10:11 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[side-by-side]]></category>
		<category><![CDATA[sxs]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/09/side-by-side-assembly/</guid>
		<description><![CDATA[什么是Side-by-Side Assembly？
Side-by-Side Assembly（建称SxS）是微软在Visual Studio 2005（Windows 2000？）中引入的技术，用来解决Windows平台上的DLL Hell问题。DLL Hell的介绍可以看Wikipedia的文章。简单的说，DL... ]]></description>
			<content:encoded><![CDATA[<h4>什么是Side-by-Side Assembly？</h4>
<p>Side-by-Side Assembly（建称SxS）是微软在Visual Studio 2005（Windows 2000？）中引入的技术，用来解决Windows平台上的DLL Hell问题。DLL Hell的介绍可以看<a href="http://en.wikipedia.org/wiki/DLL_hell" target="_blank">Wikipedia的文章</a>。简单的说，DLL Hell窘境包括了Windows应用程序依赖的DLL带来的若干问题，包括同名DLL、DLL升级、DLL载入顺序等等。</p>
<p>Side-by-Side Assembly按照我的理解，是一种特殊的DLL，按照Side-by-Side Assembly的要求开发的，并用XML格式的manifest和policy文件描述的。所有的系统Side-by-Side Assembly都安装在Windows目录下的WinSxS子目录里，有一堆的目录、DLL和XML文件。</p>
<p>Side-by-Side Assembly的使用<a href="http://msdn.microsoft.com/en-us/library/aa376307%28VS.85%29.aspx" target="_blank">参见MSDN</a>。但MSDN有把简单问题复杂化的毛病，原理讲的很多，实际例子举的很少，不看也罢。</p>
<p>使用Side-by-Side Assembly包括两个方面，一方面是自己开发的应用程序和DLL如何依赖Side-by-Side Assembly，另一方面是如何开发自己的Side-by-Side Assembly。如果只关心第一个方面，问题要简单的多。不需要关心第二个方面的原因如下。</p>
<h4></h4>
<p> <span id="more-420"></span><br />
<h4>Visual Studio 2010要取消对Side-by-Side Assembly的默认支持？</h4>
<p>消息来源于<a href="http://blogs.msdn.com/vcblog/archive/2008/10/28/visual-studio-2010-ctp-released.aspx" target="_blank">微软的博客</a>，根据文章介绍，2010要改变对应用默认采用的SxS发布方式，回到类似2003的方式，同时支持对CRT的静态和动态联编，对DLL的搜索顺序也是常用的：先搜索应用程序目录，然后System32，然后PATH。</p>
<p>当然SxS还是有的，应该只是Visual Studio不再在开发应用时默认采用。</p>
<h4>应用如何依赖Side-by-Side Assembly</h4>
<p>cl.exe在链接生成EXE的时候，会同时生成一个同名的manifest文件。该文件是XML格式的，描述了EXE对SxS的依赖。下面是一个manifest的例子：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assembly</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:asm.v1&quot;</span> <span style="color: #000066;">manifestversion</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trustinfo</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:asm.v3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;security<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;requestedprivileges<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;requestedexecutionlevel</span> <span style="color: #000066;">uiaccess</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;asInvoker&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/requestedexecutionlevel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/requestedprivileges<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/security<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trustinfo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependentassembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblyidentity</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Microsoft.VC90.CRT&quot;</span> <span style="color: #000066;">publickeytoken</span>=<span style="color: #ff0000;">&quot;1fc8b3b9a1e18e3b&quot;</span> <span style="color: #000066;">processorarchitecture</span>=<span style="color: #ff0000;">&quot;x86&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;9.0.21022.8&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;win32&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/assemblyidentity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependentassembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/assembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>如果删除这个manifest文件，运行该EXE会出现类似下面的错误：</p>
<p><a href="http://dipplum.com/wp-content/uploads/2009/11/manifesterror.png" rel="lightbox[420]"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="manifest-error" border="0" alt="manifest-error" src="http://dipplum.com/wp-content/uploads/2009/11/manifesterror_thumb.png" width="421" height="149" /></a> </p>
<p>这是因为缺少manifest文件的描述，程序不知道如何载入WinSxS目录下的DLL。所以最好把manifest文件嵌入EXE中，可以用mt.exe工具完成这一工作：</p>

<div class="wp_syntax"><div class="code"><pre class="batch" style="font-family:monospace;">mt.exe -manifest &lt;manifest-file&gt; -outputresource:&lt;exe-file&gt;;#1</pre></div></div>

<p>用IDE开发不存在这个问题，IDE会自动调用mt.exe将manifest嵌入EXE</p>
<h4>DLL如何依赖Side-by-Side Assembly</h4>
<p>同上述原因，DLL生成之后，最好也用mt.exe将manifest文件嵌入。方法与上面类似，不同之处在资源ID应该是2而不是1，其中的区别参见<a href="http://blogs.msdn.com/junfeng/archive/2007/06/26/rt-manifest-resource-and-isolation-aware-enabled.aspx" target="_blank">【1】</a><a href="http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx" target="_blank">【2】</a>，硬记也行，没什么道理。</p>

<div class="wp_syntax"><div class="code"><pre class="batch" style="font-family:monospace;">mt.exe -manifest &lt;manifest-file&gt; -outputresource:&lt;dll-file&gt;;#2</pre></div></div>

<p>用IDE开发也不存在这个问题，IDE会自动调用mt.exe将manifest嵌入DLL</p>
<h4>如何绕过Side-by-Side Assembly？</h4>
<p>Side-by-Side Assembly带来了很多不便，比如说，依赖SxS MSVCR90.dll的程序在没有安装VC redistributable的系统中不能运行，像是WinPE环境。因此最好有一种绕过SxS的方法，将SxS的Assembly和EXE放在一个目录下，避免依赖系统WinSxS目录下的Assembly。</p>
<p>1. 首先，我们需要manifest文件，如果手头没有EXE和DLL的manifest文件，可以用mt.exe工具从EXE和DLL中导出manifest文件</p>
<p>导出EXE的manifest</p>

<div class="wp_syntax"><div class="code"><pre class="batch" style="font-family:monospace;">mt.exe -inputresource:&lt;exe-file&gt;;#1 -out:&lt;manifest-file&gt;</pre></div></div>

<p>导出DLL的manifest</p>

<div class="wp_syntax"><div class="code"><pre class="batch" style="font-family:monospace;">mt.exe -outputresource:&lt;dll-file&gt;;#2 -out:&lt;manifest-file&gt;</pre></div></div>

<p>2. 根据manifest中的信息，创建若干新的manifest文件。新manifest文件名和EXE中依赖的Assembly名字对应，例如按照前面的manifest例子，应该对应创建一个Microsoft.VC90.CRT.manifest，内容格式如下：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assembly</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:asm.v1&quot;</span> <span style="color: #000066;">manifestversion</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;noinheritable<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/noinheritable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblyidentity</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Microsoft.VC90.CRT&quot;</span> <span style="color: #000066;">publickeytoken</span>=<span style="color: #ff0000;">&quot;1fc8b3b9a1e18e3b&quot;</span> <span style="color: #000066;">processorarchitecture</span>=<span style="color: #ff0000;">&quot;x86&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;9.0.21022.8&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;win32&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/assemblyidentity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;msvcr90.dll&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;msvcp90.dll&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/assembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>其中assemblyIdentity和原EXE的内容要完全一样。</p>
<p>3. 根据manifest文件中的assemblyIdentity信息，到系统的WinSxS目录下的子目录里找DLL，子目录名的格式是&lt;processorArchchitecture&gt;-&lt;name&gt;-&lt;publicKeyToken&gt;-&lt;version&gt;-none-xxx。把子目录下的DLL拷贝到EXE所在的目录下。把DLL的名字写入新manifest的file标签下。</p>
<p>至此，已经把Assembly放到EXE所在目录下，EXE也不再依赖系统WinSxS目录下的Assembly了。</p>
<h4>VC 2005和VC 2008相关的SxS打包</h4>
<p>我把自己系统中WinSxS目录下所有x86_micosoft.vc开头的目录全部拷贝出来，打了个包，以备不时之需。（<a href="http://www.uploadground.com/files/07MZXBUU/Microsoft.VCXX.SxS.zip" target="_blank">下载链接</a>）</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/09/side-by-side-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual C++ 2008编译lua</title>
		<link>http://dipplum.com/2009/11/09/visualc-compile-lua/</link>
		<comments>http://dipplum.com/2009/11/09/visualc-compile-lua/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 02:39:43 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[visualc]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/09/visualc-compile-lua/</guid>
		<description><![CDATA[1. 项目主页 http://www.lua.org/
2. 当前最新稳定版本 5.1.4，2008年8月发布
&#160;&#160;&#160; 源码下载 http://www.lua.org/ftp/lua-5.1.4.tar.gz
3. VC编译方法
&#160;&#160;&#160; 解压后，用Visual Studio 2008命令行环境进入l... ]]></description>
			<content:encoded><![CDATA[<p>1. 项目主页 <a href="http://www.lua.org/">http://www.lua.org/</a></p>
<p>2. 当前最新稳定版本 5.1.4，2008年8月发布</p>
<p>&#160;&#160;&#160; 源码下载 <a href="http://www.lua.org/ftp/lua-5.1.4.tar.gz">http://www.lua.org/ftp/lua-5.1.4.tar.gz</a></p>
<p>3. VC编译方法</p>
<p>&#160;&#160;&#160; 解压后，用Visual Studio 2008命令行环境进入lua目录，运行etc\luavs.bat。之后会在src目录下生成lua.exe、luac.exe、lua51.dll</p>
<p>4. 注意</p>
<p>&#160;&#160;&#160; 默认的luavs.bat只会生成DLL，如果需要编译静态链接库，可以自行修改luavs.bat，修改两处地方</p>
<p>&#160;&#160;&#160; 1. 删除cl.exe的编译选项 /DLUA_BUILD_AS_DLL</p>
<p>&#160;&#160;&#160; 2. 生成DLL的命令改成 lib.exe /nologo /out:lua.lib *.obj</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/09/visualc-compile-lua/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual C++ 2008编译zlib</title>
		<link>http://dipplum.com/2009/11/08/visualc-compile-zlib/</link>
		<comments>http://dipplum.com/2009/11/08/visualc-compile-zlib/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 10:27:46 +0000</pubDate>
		<dc:creator>dipplum</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[visualc]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/11/08/visualc-compile-zlib/</guid>
		<description><![CDATA[记录下Visual C++ 2008编译zlib的过程，以备不时之需。 
1. 项目主页 http://www.zlib.net/
2. 当前最新稳定版本 1.2.3，2005年7月发布
&#160;&#160;&#160;&#160;源码下载 http://www.zlib.net/zlib123.zip
3. VC编译方法
&#160;&... ]]></description>
			<content:encoded><![CDATA[<p>记录下Visual C++ 2008编译zlib的过程，以备不时之需。 </p>
<p>1. 项目主页 <a href="http://www.zlib.net/">http://www.zlib.net/</a></p>
<p>2. 当前最新稳定版本 1.2.3，2005年7月发布</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;源码下载 <a href="http://www.zlib.net/zlib123.zip">http://www.zlib.net/zlib123.zip</a></p>
<p>3. VC编译方法</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;解压后，打开项目文件projects\visualc6\zlib.dsw，新版本的VC会提示要做工程格式转换。一般只编译其中zlib项目的DLL Release和LIB Release就好了。</p>
<p>4. Bug</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;如果想编译zlib的DLL ASM Release和LIB ASM Release，会出现下面的错误：</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">contrib\masmx86\inffas32<span style="color: #339933;">.</span>asm<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">647</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">error</span> A2070<span style="color: #339933;">:</span>invalid instruction operands
contrib\masmx86\inffas32<span style="color: #339933;">.</span>asm<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">649</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">error</span> A2070<span style="color: #339933;">:</span>invalid instruction operands
contrib\masmx86\inffas32<span style="color: #339933;">.</span>asm<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">663</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">error</span> A2070<span style="color: #339933;">:</span>invalid instruction operands
contrib\masmx86\inffas32<span style="color: #339933;">.</span>asm<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">720</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">error</span> A2070<span style="color: #339933;">:</span>invalid instruction operands</pre></div></div>

<p>&nbsp;&nbsp;&nbsp;&nbsp;这是因为VC2008的MASM语法更严格了，导致之前的代码语法检查不过。参照<a href="http://www.achacha.org/vc2008_zlib123/">这里</a>的说明，把inffas32.asm改好就OK了。或者下载我<a href="http://dipplum.com/uploads/inffas32.asm">改好的</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/11/08/visualc-compile-zlib/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 2.010 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-10 21:30:44 -->
