﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-庸愚居--庸愚子的家</title><link>http://www.cppblog.com/aganno2/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 15 Apr 2026 02:05:07 GMT</lastBuildDate><pubDate>Wed, 15 Apr 2026 02:05:07 GMT</pubDate><ttl>60</ttl><item><title>VC的IDE在编译链接做了些什么--- 逆向写自己的vcspawn</title><link>http://www.cppblog.com/aganno2/archive/2006/12/14/16451.html</link><dc:creator>aganno2</dc:creator><author>aganno2</author><pubDate>Thu, 14 Dec 2006 12:21:00 GMT</pubDate><guid>http://www.cppblog.com/aganno2/archive/2006/12/14/16451.html</guid><wfw:comment>http://www.cppblog.com/aganno2/comments/16451.html</wfw:comment><comments>http://www.cppblog.com/aganno2/archive/2006/12/14/16451.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/aganno2/comments/commentRss/16451.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/aganno2/services/trackbacks/16451.html</trackback:ping><description><![CDATA[
		<div class="Section1" style="LAYOUT-GRID:  15.6pt none">
				<p style="BACKGROUND: white">
						<span style="COLOR: black">作者：</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">AGanNo2</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">Email:AGanNo2@163.com</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">1.VC</span>
						<span style="FONT-SIZE: 12pt; COLOR: blue">的</span>
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">IDE</span>
						<span style="FONT-SIZE: 12pt; COLOR: blue">在编译链接做了些什么</span>
				</p>
				<p style="BACKGROUND: white">用惯了<span lang="EN-US" style="FONT-FAMILY: Verdana">VC</span>的<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>下习惯性的点击<span lang="EN-US" style="FONT-FAMILY: Verdana">“compile”</span>和<span lang="EN-US" style="FONT-FAMILY: Verdana">“build”</span>的可能不知道在你按下这些按钮时<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>在背后到底做了写什么，对于熟悉命令行下进行编译链接的人对<span lang="EN-US" style="FONT-FAMILY: Verdana">cl.exe</span>、<span lang="EN-US" style="FONT-FAMILY: Verdana">link.exe</span>、<span lang="EN-US" style="FONT-FAMILY: Verdana">rc.exe</span>这些编译链接的工具不是陌生的，在这里我并不想讨论这些工具怎样进行编译的以及那些名目繁多的选项参数，而是从<span lang="EN-US" style="FONT-FAMILY: Verdana">“</span>亚微观<span lang="EN-US" style="FONT-FAMILY: Verdana">”<img height="19" src="http://www.cppblog.com/Emoticons/regular_smile.gif" width="19" border="0" /></span>上揭开在你点击那些按钮之后，<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>在背后干的事情，肯定有初学者像我一样想了解，当然那些<span lang="EN-US" style="FONT-FAMILY: Verdana">unix/linux</span>下的程序员以及会写<span lang="EN-US" style="FONT-FAMILY: Verdana">makefile</span>来组织编译链接进程的<span lang="EN-US" style="FONT-FAMILY: Verdana">Profession</span>的程序员就不用看下去了。</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">2.vcspawn</span>
						<span style="FONT-SIZE: 12pt; COLOR: blue">的选项和参数</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>，突然说到这个可能很多不大熟，其实在你点击那些按钮的时候，并不是由<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>自己直接去调用<span lang="EN-US" style="FONT-FAMILY: Verdana">cl.exe</span>、<span lang="EN-US" style="FONT-FAMILY: Verdana">link.exe</span>、<span lang="EN-US" style="FONT-FAMILY: Verdana">rc.exe</span>这些工具的，而是通过<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn.exe</span>这个工具进行中转的，简单说<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>把参数传递给<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>，然后由<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>来建立进程去执行这些编译链接的命令，然后把编译链接过程中的信息输出到<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>的最下面的输出窗口的，在这里<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>的输出被重定向到那个窗口了<span lang="EN-US" style="FONT-FAMILY: Verdana">(</span>一般通过管道<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span>，而由<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>新建的进程由于继承了父进程的输出，因此也会把重定向到<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>的输出窗口。</p>
				<p style="BACKGROUND: white">下面是个典型的<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>向<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>传递的参数：<span lang="EN-US" style="FONT-FAMILY: Verdana">(M$</span>对这些参数好像一点文档都没有，这些是通过调式手段截获的<img height="19" src="http://www.cppblog.com/Emoticons/regular_smile.gif" width="19" border="0" /><span lang="EN-US" style="FONT-FAMILY: Verdana">)</span></p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: blue; FONT-FAMILY: Verdana">VCSPAWN.EXE</span>
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">-e 1380 -m ~vcecho!Compiling resources...\n<br />rc.exe /l 0x804 "/foRelease/SSDowner.res" /d "NDEBUG" "D:\Microsoft Visual Studio\MyProjects\test\test.rc"\n<br />~vcecho!Compiling...\n<br />cl.exe @C:\DOCUME~1\STILLW~1\LOCALS~1\Temp\RSP5.tmp\n<br />~vcecho!Linking...\n<br />link.exe @C:\DOCUME~1\STILLW~1\LOCALS~1\Temp\RSP6.tmp\n</span>
				</p>
				<p style="BACKGROUND: white">
						<span style="COLOR: black">可以看到这里只有两个选项</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">-e</span>
						<span style="COLOR: black">和</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">-m,</span>
						<span style="COLOR: black">当然还会有其他的，后文再说</span>
				</p>
				<p style="BACKGROUND: white">其中<span lang="EN-US" style="FONT-FAMILY: Verdana">-e 1380</span>中的参数<span lang="EN-US" style="FONT-FAMILY: Verdana">1380</span>是<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>的进程句柄或者管道句柄。<span lang="EN-US" style="FONT-FAMILY: Verdana">-m</span>后面带的参数比较长，也是有规律的，据观察，他们以<span lang="EN-US" style="FONT-FAMILY: Verdana">'\0xa'</span>作为分割符，<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">~vcecho!</span><span style="COLOR: black">也是一个关键字，它表示后面的在</span><span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">\n</span><span style="COLOR: black">之前的字符串将被输出到</span><span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">IDE</span><span style="COLOR: black">的输出窗口里，这样我们在编译的过程中也就看到了</span><span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">Compiling resources...</span><span style="COLOR: red">、</span><span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">Compiling...</span><span style="COLOR: red">、</span><span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">Linking...</span><span style="COLOR: black">这些表示编译进程的信息，类似</span><span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">~vcecho!</span><span style="COLOR: black">的词还有</span><span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">~vctime!</span><span style="COLOR: black">和</span><span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">~vcsleep!</span><span style="COLOR: black">，我想不用多解释就明白它们是什么意思了。</span></p>
				<p style="BACKGROUND: white">下面看由<span lang="EN-US" style="FONT-FAMILY: Verdana">'\0xa'</span>分割得到的其它三句：</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">rc.exe /l 0x804 "/foRelease/SSDowner.res" /d "NDEBUG" "D:\Microsoft Visual Studio\MyProjects\test\test.rc"</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">cl.exe @C:\DOCUME~1\STILLW~1\LOCALS~1\Temp\RSP5.tmp</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">link.exe @C:\DOCUME~1\STILLW~1\LOCALS~1\Temp\RSP6.tmp</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">vcspawn</span>
						<span style="COLOR: black">将把这些做为命令行分别建立新的进程。在这里，很明显只有</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">rc.exe</span>
						<span style="COLOR: black">给出了比较详细的链接参数，也难怪因为一般资源文件只有一个就够了，而源文件和目标文件会有多个，于是</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">cl.exe</span>
						<span style="COLOR: black">和</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">link.exe</span>
						<span style="COLOR: black">的参数中只有它们的临时文件，这些临时文件</span>
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">RSP5.tmp</span>
						<span style="COLOR: black">和</span>
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">RSP6.tmp</span>
						<span style="COLOR: black">（名称随机）的内容大致如下：</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">(</span>
						<span style="COLOR: black">在</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">IDE</span>
						<span style="COLOR: black">清理删除它们之前拷贝过来的</span>
						<img height="19" src="http://www.cppblog.com/Emoticons/regular_smile.gif" width="19" border="0" />
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">)</span>
						<span style="COLOR: black">：</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">RSP5.tmp</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/test.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c <br />"D:\Microsoft Visual Studio\MyProjects\test\main.c"</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">RSP6.tmp</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/test.pdb" /machine:I386 /out:"Release/test.exe" <br />".\Release\main.obj"</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">".\Release\test.res"</span>
				</p>
				<p style="BACKGROUND: white">分别是编译器<span lang="EN-US" style="FONT-FAMILY: Verdana">(cl.exe)</span>和链接器<span lang="EN-US" style="FONT-FAMILY: Verdana">(linke.exe)</span>的参数，熟悉命令行编译链接的对这些应该很熟悉。</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>除了<span lang="EN-US" style="FONT-FAMILY: Verdana">-e</span>和<span lang="EN-US" style="FONT-FAMILY: Verdana">-m</span>这连个参数外，还有<span lang="EN-US" style="FONT-FAMILY: Verdana">-t -p(</span>一般放在一块<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span>，甚至在你点击<span lang="EN-US" style="FONT-FAMILY: Verdana">“execute”(</span>执行<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span>的时候，也并不是由<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>去直接执行连接后的可执行文件，而还是由<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>作为中转，<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>启动可执行文件的参数如下<span lang="EN-US" style="FONT-FAMILY: Verdana">:(</span>这个<span lang="EN-US" style="FONT-FAMILY: Verdana">bill</span>也不告诉俺<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span></p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="COLOR: red; FONT-FAMILY: Verdana">vcspawn.exe -t -p 'D:\Microsoft Visual Studio\MyProjects\test\Release\test.exe"</span>
				</p>
				<p style="BACKGROUND: white">
						<span style="COLOR: black">这个就可以解释为什么在</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">IDE</span>
						<span style="COLOR: black">下点击</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">“execute”</span>
						<span style="COLOR: black">去执行编译后的程序后都会有</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">"Press any key to continue"</span>
						<span style="COLOR: black">这句，而且在按了一个键后才结束，这些在我们的程序中并没有这些，这些都是位于</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">vcspawn.exe</span>
						<span style="COLOR: black">中的，这也是初学者直接点击一个自己写的</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">console</span>
						<span style="COLOR: black">程序后看到屏幕一闪而过的原因</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">(</span>
						<span style="COLOR: black">当然并非所有的程序都这样</span>
						<img height="19" src="http://www.cppblog.com/Emoticons/regular_smile.gif" width="19" border="0" />
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">)</span>
				</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">3.</span>
						<span style="FONT-SIZE: 12pt; COLOR: blue">逆向写兼容的</span>
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">vcspawn</span>
				</p>
				<p style="BACKGROUND: white">在通过阅读<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>的反汇编代码了解其大致流程后，就开始了俺的逆向重构的过程，用的是<span lang="EN-US" style="FONT-FAMILY: Verdana">C</span>，由于严格按照<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>的反汇编代码的逻辑来写的，所以花了我近一天的时间，力求做到逻辑上的一致<span lang="EN-US" style="FONT-FAMILY: Verdana">(</span>甚至是汇编代码级别上的，吹牛啦<span lang="EN-US" style="FONT-FAMILY: Verdana"><img height="19" src="/aganno2/admin/新建%20Microsoft%20Word%20文档.files/image001.gif" width="19" />)</span>，由于<span lang="EN-US" style="FONT-FAMILY: Verdana">VC6.0</span>的<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>的版本是<span lang="EN-US" style="FONT-FAMILY: Verdana">6.00</span>的，因此自己写的兼容的<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>在<span lang="EN-US" style="FONT-FAMILY: Verdana">vc6.0</span>和<span lang="EN-US" style="FONT-FAMILY: Verdana">evc4.2</span>上工作的很好<span lang="EN-US" style="FONT-FAMILY: Verdana">(</span>放在我机器<span lang="EN-US" style="FONT-FAMILY: Verdana">D:\Microsoft Visual Studio\Common\MSDev98\Bin</span>这个目录里，覆盖原版<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span>，不禁窃喜<img height="19" src="http://www.cppblog.com/Emoticons/teeth_smile.gif" width="19" border="0" />，<span lang="EN-US" style="FONT-FAMILY: Verdana">vc2003</span>的看了一下，也无多大区别<span lang="EN-US" style="FONT-FAMILY: Verdana">(</span>参数有点区别<span lang="EN-US" style="FONT-FAMILY: Verdana">)</span>，已无兴趣再做重复的事情。</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>大都调用的都是<span lang="EN-US" style="FONT-FAMILY: Verdana">msvcrt</span>这个库的东西，而且是多线程动态链接的<span lang="EN-US" style="FONT-FAMILY: Verdana">(/MD),</span>编译连接后体积只有<span lang="EN-US" style="FONT-FAMILY: Verdana">7.5k,</span>可谓小巧。</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-SIZE: 12pt; COLOR: blue; FONT-FAMILY: Verdana">4.</span>
						<span style="FONT-SIZE: 12pt; COLOR: blue">这个有什么用？</span>
				</p>
				<p style="BACKGROUND: white">
						<span style="COLOR: black">是啊，有什么用呢，在我自己写的</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">vcspawn</span>
						<span style="COLOR: black">中我实现了输出那些编译链接的细节，就差没把临时文件拷过来了</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">(</span>
						<span style="COLOR: black">这个不难</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">)</span>
						<span style="COLOR: black">，其它的可以在其中加入自己要执行的命令或者输出一些更详细的信息。不过说过来好像还是无大用处，不过使我自己独自的弄明白了</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">IDE</span>
						<span style="COLOR: black">到底干了些啥，顺便练了下逆向工程</span>
						<span lang="EN-US" style="COLOR: black; FONT-FAMILY: Verdana">
								<img height="19" src="http://www.cppblog.com/Emoticons/regular_smile.gif" width="19" border="0" />
						</span>
				</p>
				<p style="BACKGROUND: white">最后抓个图留做纪念</p>
				<p style="BACKGROUND: white">
						<span lang="EN-US" style="FONT-FAMILY: Verdana">
								<img height="288" src="http://www.cppblog.com/images/cppblog_com/aganno2/3271/r_vcspawn.gif" width="639" />
								<br />
						</span>其中红色的部分是兼容性版本的<span lang="EN-US" style="FONT-FAMILY: Verdana">vcspawn</span>输出的编译链接中输出的详细信息。</p>
				<p class="MsoNormal">
						<span lang="EN-US">最后附上源代码及编译好的可执行文件<a href="/Files/aganno2/vcspawn.zip">http://www.cppblog.com/Files/aganno2/vcspawn.zip</a></span>
				</p>
		</div>
<img src ="http://www.cppblog.com/aganno2/aggbug/16451.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/aganno2/" target="_blank">aganno2</a> 2006-12-14 20:21 <a href="http://www.cppblog.com/aganno2/archive/2006/12/14/16451.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC6.0 SP6的IDE的一个BUG？</title><link>http://www.cppblog.com/aganno2/archive/2006/11/25/15661.html</link><dc:creator>aganno2</dc:creator><author>aganno2</author><pubDate>Sat, 25 Nov 2006 12:15:00 GMT</pubDate><guid>http://www.cppblog.com/aganno2/archive/2006/11/25/15661.html</guid><wfw:comment>http://www.cppblog.com/aganno2/comments/15661.html</wfw:comment><comments>http://www.cppblog.com/aganno2/archive/2006/11/25/15661.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/aganno2/comments/commentRss/15661.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/aganno2/services/trackbacks/15661.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">这是前一阶段发现的，由于解决该问题花费了我几乎半天的时间，因此记忆犹新！<br />BUG描述：<br />        在VC6.0 SP6中(我用的是中文版)在逻辑驱动器根目录下的名为template的目录中建立的工程用IDE提供的编译按钮默认不会编译！<br />        举个例子，在目录F:\template或C:\template\123目录下建立的工程Test，Test中只有一个文件test.cpp，当点击菜单中的“编译”或“组建”按钮时，貌似编译完成了，见到了</font>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">--------------------</span>
				<span style="COLOR: #000000">Configuration: Test </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000"> Win32 Debug</span>
				<span style="COLOR: #000000">--------------------</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />test.cpp </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> error(s), </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> warning(s)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
		</div>
		<br />提示。这时点击执行时出现错误，如下所示：<br /><img height="114" alt="cc.GIF" src="http://www.cppblog.com/images/cppblog_com/aganno2/cc.GIF" width="184" border="0" /><br />这时到工程的目录下面看时确实没有编译和连接，没有生成test.obj和test.exe文件。<br />怀疑是test.dsp出了问题，因为VC6.0的IDE的编译依据是*.dsp和*.dsw这两个描述工程的文件。通过对照发现如下不同：<br /><br />IDE不能编译的Test工程test.dsp中：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><p><span style="COLOR: #000000"><font style="BACKGROUND-COLOR: #eeeeee"># Begin Group "Source Files"</font></span></p><p><span style="COLOR: #000000"><font style="BACKGROUND-COLOR: #eeeeee"># PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"<br /><font color="#ff0000"># Begin Source File</font></font></span></p><p><span style="COLOR: #000000"><font style="BACKGROUND-COLOR: #eeeeee"><font color="#ff0000">SOURCE=.\test.cpp<br /># PROP Exclude_From_Scan -1<br /># PROP BASE Exclude_From_Build 1<br /># PROP Exclude_From_Build 1<br /># End Source File</font><br /># End Group</font></span></p></div><br />IDE能编译的Test工程test.dsp中：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000"># Begin Group </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Source Files</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /># PROP Default_Filter </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /># End Group</span></div> 上面只列出料两个文件的不同处，小弟不懂dsp文件的格式，但单由IDE不能编译的Test工程test.dsp中的Exclude_From_Scan Exclude_From_Build 这些字眼中猜想意思应该是test.cpp文件没有在被编译的文件之列，所以IDE下编译不能进行！(麻烦哪儿有关dsp文件资料的告诉个地方！)<br />当然修改test.dsp文件后又能正确编译了！<br />直接在命令行下直接编译是能成功的(cl test.cpp)<br /><br />另外，经测试发现，不能用VC6.0 sp6中的IDE的工具创建名字为template的工程，会出现以下错误：<br /><img height="114" alt="cw2.GIF" src="http://www.cppblog.com/images/cppblog_com/aganno2/cw2.GIF" width="249" border="0" /><br />好了，就是这么多了，搞不清楚这是VC的IDE的BUG，还是M$默认的规则，不过在VC2003下没有上述错误发生，看来旧的东西是要被代替的，怎乃用VC6.0太久，舍不得割舍~~<br />这儿描述的问题也许您从来不会遇到过，不过就是俺遇到了，记下，留个纪念~~<br />这也是俺在C++blog园的第一段文字！<br /><img src ="http://www.cppblog.com/aganno2/aggbug/15661.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/aganno2/" target="_blank">aganno2</a> 2006-11-25 20:15 <a href="http://www.cppblog.com/aganno2/archive/2006/11/25/15661.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>