<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>绿色记忆 &#187; MSVC</title>
	<atom:link href="https://blog.gmem.cc/tag/msvc/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.gmem.cc</link>
	<description></description>
	<lastBuildDate>Tue, 28 Apr 2026 02:49:28 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.14</generator>
	<item>
		<title>Windows下基于Eclipse CDT的C/C++开发</title>
		<link>https://blog.gmem.cc/eclipse-cdt-based-dev</link>
		<comments>https://blog.gmem.cc/eclipse-cdt-based-dev#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:41:07 +0000</pubDate>
		<dc:creator><![CDATA[Alex]]></dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[CDT]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[MinGW]]></category>
		<category><![CDATA[MSVC]]></category>

		<guid isPermaLink="false">http://blog.gmem.cc/?p=2029</guid>
		<description><![CDATA[<p>安装和配置 安装Eclipse CDT 到Eclipse CDT官网下载：http://www.eclipse.org/cdt/并安装 Eclipse的相关配置可以参考：Eclipse 4.3.2开发环境搭建 安装工具链 下面的工具链可以根据工作环境进行选择性的安装。 MinGW 安装MinGW，下载地址：http://sourceforge.net/projects/mingw/files/ 安装MSYS，到http://sourceforge.net/projects/mingw/files/MSYS/下载 mingw-get-setup.exe，然后双击安装，选择安装目录为%MINGW_HOME%，勾选MSYS base，进行安装 将%MINGW_HOME%\bin添加到PATH环境变量，以便Eclipse CDT识别此工具链 MinGW-w64 安装MinGW-w64，下载地址：http://mingw-w64.org/doku.php 复制%MINGW_W64%\x86_64-w64-mingw32-gcc.exe（对于32位版本则是i686-w64-mingw32-gcc.exe）为mingw32-gcc.exe，便于Eclipse识别工具链 安装MSYS，下载地址：SourceForge 将%MINGW_W64%\mingw32\bin目录加入到PATH环境变量，以便Eclipse CDT识别此工具链 注意，Eclipse不能区分MinGW和MinGW-w64。因此，如果机器上同时安装这两套工具链，只应该设置其中常用的到环境变量PATH中。当需要使用另外一套工具链时，设置Eclipse项目属性 <a class="read-more" href="https://blog.gmem.cc/eclipse-cdt-based-dev">[...]</a></p>
<p>The post <a rel="nofollow" href="https://blog.gmem.cc/eclipse-cdt-based-dev">Windows下基于Eclipse CDT的C/C++开发</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></description>
				<content:encoded><![CDATA[<div class="wri_content_clear_both"><div class="blog_h1"><span class="graybg">安装和配置</span></div>
<div class="blog_h2"><span class="graybg">安装Eclipse CDT</span></div>
<ol>
<li>到Eclipse CDT官网下载：<a href="http://www.eclipse.org/cdt/">http://www.eclipse.org/cdt/</a>并安装</li>
<li>Eclipse的相关配置可以参考：<a href="/eclipse-kepler-sr2-setup#workspace-config">Eclipse 4.3.2开发环境搭建</a></li>
</ol>
<div class="blog_h2"><span class="graybg">安装工具链</span></div>
<p>下面的工具链可以根据工作环境进行选择性的安装。</p>
<div class="blog_h3"><span class="graybg">MinGW</span></div>
<ol>
<li>安装MinGW，下载地址：<a href="http://sourceforge.net/projects/mingw/files/">http://sourceforge.net/projects/mingw/files/</a></li>
<li>安装MSYS，到<a href="http://sourceforge.net/projects/mingw/files/MSYS/">http://sourceforge.net/projects/mingw/files/MSYS/</a>下载 mingw-get-setup.exe，然后双击安装，选择安装目录为%MINGW_HOME%，勾选MSYS base，进行安装</li>
<li>将%MINGW_HOME%\bin添加到PATH环境变量，以便Eclipse CDT识别此工具链</li>
</ol>
<div class="blog_h3"><span class="graybg">MinGW-w64</span></div>
<ol>
<li>安装MinGW-w64，下载地址：<a href="http://mingw-w64.org/doku.php">http://mingw-w64.org/doku.php</a></li>
<li>复制%MINGW_W64%\x86_64-w64-mingw32-gcc.exe（对于32位版本则是i686-w64-mingw32-gcc.exe）为mingw32-gcc.exe，便于Eclipse识别工具链</li>
<li>安装MSYS，下载地址：<a href="http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/">SourceForge</a></li>
<li>将%MINGW_W64%\mingw32\bin目录加入到PATH环境变量，以便Eclipse CDT识别此工具链</li>
</ol>
<p>注意，Eclipse不能区分MinGW和MinGW-w64。因此，如果机器上同时安装这两套工具链，只应该设置其中常用的到环境变量PATH中。当需要使用另外一套工具链时，设置Eclipse项目属性 - C/C++ Build - Environment，添加环境变量MINGW_HOME，并点选“Replace native environment with specified one”</p>
<div class="blog_h3"><span class="graybg">Cygwin</span></div>
<ol>
<li>安装Cygwin：<a href="http://cygwin.com/setup-x86.exe">http://cygwin.com/setup-x86.exe</a>，选择一个安装目录，例如（D:\CPP\tools\Cygwin\，以下称%CYGWIN_HOME%）</li>
<li>在Select Packages步骤下，选择Devel中的：autoconf、automake、binutils、gdb、gcc-core、gcc-g++、libtool、make，以及wget，下一步进行安装，其它需要的工具或者库，可以随时使用此安装程序安装</li>
<li>将 %CYGWIN_HOME%\bin、%CYGWIN_HOME%\usr\local\bin添加到PATH环境变量，以便Eclipse CDT识别此工具链</li>
<li>（可选步骤）为了后续安装软件包方便，可安装apt-cyg：<br />
<pre class="crayon-plain-tag">wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin/</pre>
</li>
</ol>
<div class="blog_h3"><span class="graybg">LLVM</span></div>
<p>本节假设已经安装了MinGW工具链+MSYS，并在其上搭建LLVM工具链，步骤如下：</p>
<ol>
<li>安装Eclipse对LLVM工具链的支持：添加Update Site：<a href="http://petrituononen.com/llvm4eclipsecdt/update">http://petrituononen.com/llvm4eclipsecdt/update</a> 并安装</li>
<li>进入MSYS终端，执行以下脚本，以构建LLVM：<br />
<pre class="crayon-plain-tag">#签出LLVM源码
cd /src
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd /src/llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd /src/llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
#配置和构建
cd /src/llvm
./configure --prefix=/mingw32 --enable-optimized --disable-assertions 
make
make install</pre>
</li>
</ol>
<div class="blog_h3"><span class="graybg">MSVC</span></div>
<ol>
<li>安装Microsoft Visual Studio</li>
<li>Eclipse - Help - Install New Software，选择Eclipse CDT的Update Site，下一步中，在Optional中选择 C/C++ Visual C++ Support，进行安装</li>
</ol>
<div class="blog_h2"><span class="graybg">创建Eclipse C/C++工程</span></div>
<p>通过Eclipse - File - New - C/C++ Project即可创建C或者C++的工程，创建时需要选择工具链，某些工具链的需要额外的设置，具体如下：</p>
<div class="blog_h3"><span class="graybg">LLVM</span></div>
<ol>
<li>C/C++ General - Path and Symbols <br />Includes - GNU C++<br />
<table style="width: 100%;" border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<td style="text-align: center;">Debug</td>
</tr>
</thead>
<tbody>
<tr>
<td>%MinGW_HOME%\include<br />%MinGW_HOME%\lib\gcc\mingw32\4.8.1\include<br />%MinGW_HOME%\lib\gcc\mingw32\4.8.1\include\c++<br />%MinGW_HOME%\lib\gcc\mingw32\4.8.1\include\c++\mingw32</td>
</tr>
</tbody>
</table>
<p>Symbols - GNU C++</p>
<table style="width: 100%;" border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<td style="text-align: center;"> Debug</td>
<td style="text-align: center;">Release </td>
</tr>
</thead>
<tbody>
<tr>
<td> __MSVCRT__=1</td>
<td> __MSVCRT__=1</td>
</tr>
</tbody>
</table>
<p>Libraries - GNU C++</p>
<table style="width: 100%;" border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<td style="text-align: center;"> Debug</td>
<td style="text-align: center;">Release </td>
</tr>
</thead>
<tbody>
<tr>
<td>stdc++</td>
<td>stdc++</td>
</tr>
</tbody>
</table>
<p>Library Paths- GNU C++</p>
<table style="width: 100%;" border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<td style="text-align: center;"> Debug</td>
<td style="text-align: center;">Release </td>
</tr>
</thead>
<tbody>
<tr>
<td>%MinGW_HOME%\lib\gcc\mingw32\4.8.1</td>
<td>%MinGW_HOME%\lib\gcc\mingw32\4.8.1</td>
</tr>
</tbody>
</table>
</li>
<li>C/C++ Build - Settings <br /> Tool Settings - LLVM C++ Linker：Command改为clang</li>
<li>如果同时安装了Cygwin，可能需要把%Cygwin%下在环境变量PATH中条目移除；可能需要把MSYS相关的条目从PATH中移除</li>
</ol>
<div class="blog_h1"><span class="graybg">常见问题</span></div>
<div class="blog_h3"><span class="graybg">使用GCC时如何创建Windows窗体应用程序</span></div>
<p>设置链接标记，在Eclipse下：Properties - C/C++ Build -Settings - MinGW C++ Linker - Misc - Linker flags，添加<pre class="crayon-plain-tag">-mwindows</pre> ，即可提示链接器创建的是窗口应用，额外添加 -mconsole 则可同时获得一个控制台窗口。</p>
<div class="blog_h3"><span class="graybg">如何为应用程序添加资源文件</span></div>
<ol>
<li>Properties - C/C++ Build -Settings - Build Steps - Pre-build steps，添加调用windres的脚本，例子可以参考<a href="/wxwidgets-development-with-eclipse-cdt#prebuild-script-for-rc-file">《基于Eclipse CDT的wxWidgets开发环境搭建》</a></li>
<li>把上面编译好的*.o文件添加到Properties - C/C++ Build -Settings - MinGW C++ Linker - Misc - Other objects里</li>
</ol>
</div><p>The post <a rel="nofollow" href="https://blog.gmem.cc/eclipse-cdt-based-dev">Windows下基于Eclipse CDT的C/C++开发</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.gmem.cc/eclipse-cdt-based-dev/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
