<?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>使用 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/%E4%BD%BF%E7%94%A8/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Wed, 31 May 2023 02:41:54 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] Emacs文章合集</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-emacs%e6%96%87%e7%ab%a0%e5%90%88%e9%9b%86/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-emacs%e6%96%87%e7%ab%a0%e5%90%88%e9%9b%86/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 28 Mar 2014 16:55:39 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[tree mode]]></category>
		<category><![CDATA[tree view]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[总结]]></category>
		<category><![CDATA[树形]]></category>
		<category><![CDATA[树状]]></category>
		<category><![CDATA[资源管理器]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=7988</guid>

					<description><![CDATA[<p>转载请注明出处：<strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;"><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 0, 0);">http://www.codelast.com/</span></a></span></strong></p>
<p>文章越来越多，越来越不好查询了，只能一点点归类。</p>
<p><span style="background-color:#00ff00;">➤&#160;</span><a href="http://www.codelast.com/?p=4802" rel="noopener noreferrer" target="_blank">Emacs on Windows初步实践</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span><a href="http://www.codelast.com/?p=7980" rel="noopener noreferrer" target="_blank">在Emacs中使用树形&#8220;资源管理器&#8221;&#8212;&#8212;emacs-nav</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span><a href="http://www.codelast.com/?p=7971" rel="noopener noreferrer" target="_blank">在Emacs中使用树形&#8220;资源管理器&#8221;&#8212;&#8212;Sr Speedbar</a><br />
<span id="more-7988"></span><br />
<span style="background-color: rgb(0, 255, 0);">➤&#160;</span>配置Emacs自动完成/自动补全：<a href="http://www.codelast.com/?p=4945" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第6条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span><a href="http://www.codelast.com/?p=159" rel="noopener noreferrer" target="_blank">Emacs解除read-only的buffer锁定</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span>在Emacs中显示UTF-8编码的文件内容/显示中文：<a href="http://www.codelast.com/?p=4048" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第13条<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);">➤&#160;</span>在Xshell终端里启用Emacs的Meta key：<a href="http://www.codelast.com/?p=4048" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第14条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span>使Emacs不要生成临时文件：<a href="http://www.codelast.com/?p=3645" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第1条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span>为Emacs自定义&#8220;跳到指定行&#8221;的快捷键 &#38; &#8220;替换字符串&#8221;的快捷键：<a href="http://www.codelast.com/?p=3645" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第19条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span>CEDET的安装及基本配置：<a href="http://www.codelast.com/?p=151" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第39条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span>Emacs启动时报错&#8220;Wrong type argument: stringp&#8221;的解决办法：<a href="http://www.codelast.com/?p=151" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第54条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&#160;</span><a href="http://www.codelast.com/?p=8337" rel="noopener noreferrer" target="_blank">解决找不到emacsclient命令的问题 / Solve the emacsclient: command not found problem</a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-emacs%e6%96%87%e7%ab%a0%e5%90%88%e9%9b%86/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>转载请注明出处：<strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;"><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 0, 0);">http://www.codelast.com/</span></a></span></strong></p>
<p>文章越来越多，越来越不好查询了，只能一点点归类。</p>
<p><span style="background-color:#00ff00;">➤&nbsp;</span><a href="http://www.codelast.com/?p=4802" rel="noopener noreferrer" target="_blank">Emacs on Windows初步实践</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span><a href="http://www.codelast.com/?p=7980" rel="noopener noreferrer" target="_blank">在Emacs中使用树形&ldquo;资源管理器&rdquo;&mdash;&mdash;emacs-nav</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span><a href="http://www.codelast.com/?p=7971" rel="noopener noreferrer" target="_blank">在Emacs中使用树形&ldquo;资源管理器&rdquo;&mdash;&mdash;Sr Speedbar</a><br />
<span id="more-7988"></span><br />
<span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>配置Emacs自动完成/自动补全：<a href="http://www.codelast.com/?p=4945" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第6条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span><a href="http://www.codelast.com/?p=159" rel="noopener noreferrer" target="_blank">Emacs解除read-only的buffer锁定</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>在Emacs中显示UTF-8编码的文件内容/显示中文：<a href="http://www.codelast.com/?p=4048" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第13条<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>在Xshell终端里启用Emacs的Meta key：<a href="http://www.codelast.com/?p=4048" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第14条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>使Emacs不要生成临时文件：<a href="http://www.codelast.com/?p=3645" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第1条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>为Emacs自定义&ldquo;跳到指定行&rdquo;的快捷键 &amp; &ldquo;替换字符串&rdquo;的快捷键：<a href="http://www.codelast.com/?p=3645" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第19条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>CEDET的安装及基本配置：<a href="http://www.codelast.com/?p=151" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第39条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>Emacs启动时报错&ldquo;Wrong type argument: stringp&rdquo;的解决办法：<a href="http://www.codelast.com/?p=151" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">此文</span></a>第54条</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span><a href="http://www.codelast.com/?p=8337" rel="noopener noreferrer" target="_blank">解决找不到emacsclient命令的问题 / Solve the emacsclient: command not found problem</a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span><a href="https://www.codelast.com/?p=13891" rel="noopener" target="_blank">设置Emacs打开一个文件时的&quot;文件太大&quot;警告阈值</a></p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>批量注释多行：先按 CTRL+@ 开始区域选择，再按上下左右键选中要注释的多行内容，最后按 Alt+; 即可批量注释掉选中的行</p>
<p><span style="background-color: rgb(0, 255, 0);">➤&nbsp;</span>To be added...</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-emacs%e6%96%87%e7%ab%a0%e5%90%88%e9%9b%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 如何在Ubuntu下的VirtualBox虚拟机（Windows XP）里挂载/使用U盘</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%a6%82%e4%bd%95%e5%9c%a8ubuntu%e4%b8%8b%e7%9a%84virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%ef%bc%88windows-xp%ef%bc%89%e9%87%8c%e6%8c%82%e8%bd%bd%e4%bd%bf%e7%94%a8u%e7%9b%98/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%a6%82%e4%bd%95%e5%9c%a8ubuntu%e4%b8%8b%e7%9a%84virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%ef%bc%88windows-xp%ef%bc%89%e9%87%8c%e6%8c%82%e8%bd%bd%e4%bd%bf%e7%94%a8u%e7%9b%98/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 23 Mar 2014 08:20:13 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[U盘]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[优盘]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[找不到U盘]]></category>
		<category><![CDATA[挂载]]></category>
		<category><![CDATA[虚拟机]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=7952</guid>

					<description><![CDATA[<p>
在Ubuntu下安装了VirtualBox之后，如果你的虚拟机安装的是Windows XP系统，那么，你会发现，当你插上U盘时，无论你怎么折腾，虚拟机（XP）里都是没有任何反应的，既不提示找到新硬件，也看不到U盘的分区。<br />
不像VMware，默认安装之后对U盘的支持很好，根本不需要用户去配置什么东西。从这一点上，我觉得VirtualBox太龌龊了，小而美归小而美，但是你不能把最常用的功能放在基础支持列表之外，还要用户去配置才能用，不是么？</p>
<p>下面就教你如何能让VirtualBox的虚拟机（XP）找到U盘并挂载上。宿主机系统是Ubuntu。实话说，网上的很多文章写得实在让人很无语，要么简略得太夸张，要么连中文都写得不通顺（负点责任行吗），我实在是看不下去了，所以在研究出来怎么做之后，我决定要把这么简单的一件事情写成教程，帮助有需要的人。<br />
<span id="more-7952"></span><br />
<span style="background-color:#00ff00;">『1』</span>关于Guest Additions<br />
VirtualBox带有一个叫Guest Additions的东西，可以在VirtualBox的菜单里为虚拟机安装上（一点击，在XP中就会弹出软件安装界面）。后面的步骤是否依赖Guest Additions，我<span style="color:#0000ff;">不确定</span>，因此，建议你安装上。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『2』</span>U盘的支持在哪里<br />
你一定想不到，默认安装的VirtualBox，竟然是没有USB设备支持功能的！你必须要去它的官网下载另一个&#8220;扩展包&#8221;（Oracle VM VirtualBox Extension Pack），才能让VirtualBox支持！如前所述，我觉得这一点非常让人无语。<br />
下载地址在VirtualBox官网可以找到。在我写这篇文章的时候，我下载的版本是&#160;<strong>VirtualBox 4.3.8 Oracle VM VirtualBox Extension Pack</strong>，文件名为&#160;Oracle_VM_VirtualBox_Extension_Pack-4.3.8-92456.vbox-extpack，双击它进行安装（前提是你已经安装过了VirtualBox软件，否则双击它是没用的）。<br />
双击时，会弹出类似于下面的对话框：</p>
<div style="text-align: center;">
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/virtualbox_extension_pack_install.jpg" style="width: 439px; height: 245px;" /></div>
<p>点击&#8220;安装&#8221;，毫无疑问。</p>
<p><span style="background-color:#00ff00;">『3』</span>添加用户组<br />
在Ubuntu命令行下，执行如下命令：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo adduser your_user_name vboxusers
</pre>
<p>其中，your_user_name 是你用来运行VirtualBox的Linux用户名，你要根据实际情况更改。</p>
<p><span style="background-color:#00ff00;">『4』</span>重启宿主机<br />
是的，重启宿主机。貌似注销也行，但是不要去猜和尝试了，重启宿主机是一定有效的。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%a6%82%e4%bd%95%e5%9c%a8ubuntu%e4%b8%8b%e7%9a%84virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%ef%bc%88windows-xp%ef%bc%89%e9%87%8c%e6%8c%82%e8%bd%bd%e4%bd%bf%e7%94%a8u%e7%9b%98/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
在Ubuntu下安装了VirtualBox之后，如果你的虚拟机安装的是Windows XP系统，那么，你会发现，当你插上U盘时，无论你怎么折腾，虚拟机（XP）里都是没有任何反应的，既不提示找到新硬件，也看不到U盘的分区。<br />
不像VMware，默认安装之后对U盘的支持很好，根本不需要用户去配置什么东西。从这一点上，我觉得VirtualBox太龌龊了，小而美归小而美，但是你不能把最常用的功能放在基础支持列表之外，还要用户去配置才能用，不是么？</p>
<p>下面就教你如何能让VirtualBox的虚拟机（XP）找到U盘并挂载上。宿主机系统是Ubuntu。实话说，网上的很多文章写得实在让人很无语，要么简略得太夸张，要么连中文都写得不通顺（负点责任行吗），我实在是看不下去了，所以在研究出来怎么做之后，我决定要把这么简单的一件事情写成教程，帮助有需要的人。<br />
<span id="more-7952"></span><br />
<span style="background-color:#00ff00;">『1』</span>关于Guest Additions<br />
VirtualBox带有一个叫Guest Additions的东西，可以在VirtualBox的菜单里为虚拟机安装上（一点击，在XP中就会弹出软件安装界面）。后面的步骤是否依赖Guest Additions，我<span style="color:#0000ff;">不确定</span>，因此，建议你安装上。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『2』</span>U盘的支持在哪里<br />
你一定想不到，默认安装的VirtualBox，竟然是没有USB设备支持功能的！你必须要去它的官网下载另一个&ldquo;扩展包&rdquo;（Oracle VM VirtualBox Extension Pack），才能让VirtualBox支持！如前所述，我觉得这一点非常让人无语。<br />
下载地址在VirtualBox官网可以找到。在我写这篇文章的时候，我下载的版本是&nbsp;<strong>VirtualBox 4.3.8 Oracle VM VirtualBox Extension Pack</strong>，文件名为&nbsp;Oracle_VM_VirtualBox_Extension_Pack-4.3.8-92456.vbox-extpack，双击它进行安装（前提是你已经安装过了VirtualBox软件，否则双击它是没用的）。<br />
双击时，会弹出类似于下面的对话框：</p>
<div style="text-align: center;">
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/virtualbox_extension_pack_install.jpg" style="width: 439px; height: 245px;" /></div>
<p>点击&ldquo;安装&rdquo;，毫无疑问。</p>
<p><span style="background-color:#00ff00;">『3』</span>添加用户组<br />
在Ubuntu命令行下，执行如下命令：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo adduser your_user_name vboxusers
</pre>
<p>其中，your_user_name 是你用来运行VirtualBox的Linux用户名，你要根据实际情况更改。</p>
<p><span style="background-color:#00ff00;">『4』</span>重启宿主机<br />
是的，重启宿主机。貌似注销也行，但是不要去猜和尝试了，重启宿主机是一定有效的。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『5』</span>挂载U盘<br />
重启宿主机后，先插上U盘，再启动虚拟机（XP），点击此虚拟机的VirtualBox菜单：<span style="color:#0000ff;">设备</span>&rarr;<span style="color:#0000ff;">分配USB设备</span>，在列出的USB设备列表中找到你的U盘名字，点击。然后虚拟机（XP）里应该就会出现找到新硬件的提示了。<br />
如若不行，你可能需要在VirtualBox的全局设置中的&ldquo;<span style="color:#0000ff;">USB设备</span>&rdquo;设置里，将&ldquo;<span style="color:#0000ff;">启用USB2.0（EHCI）控制器</span>&rdquo;选中，再重启虚拟机试试。</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%a6%82%e4%bd%95%e5%9c%a8ubuntu%e4%b8%8b%e7%9a%84virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%ef%bc%88windows-xp%ef%bc%89%e9%87%8c%e6%8c%82%e8%bd%bd%e4%bd%bf%e7%94%a8u%e7%9b%98/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] Google Protocol Buffers中文教程</title>
		<link>https://www.codelast.com/google-protocol-buffers%e4%b8%ad%e6%96%87%e6%95%99%e7%a8%8b/</link>
					<comments>https://www.codelast.com/google-protocol-buffers%e4%b8%ad%e6%96%87%e6%95%99%e7%a8%8b/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 27 Oct 2013 08:43:29 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[Avro]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[MessagePack]]></category>
		<category><![CDATA[Protocol Buffer]]></category>
		<category><![CDATA[Protocol Buffers]]></category>
		<category><![CDATA[Thrift]]></category>
		<category><![CDATA[中文]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[教程]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=8</guid>

					<description><![CDATA[<p>
	注：前面这些是本人的翻译，可能不准确，可能有错误，但是基本上可以理解，希望能对大家有所帮助。</p>
<div>
	<a href="http://www.codelast.com/?p=280" rel="noopener noreferrer" target="_blank">Protocol Buffer Basics: C++中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&#160;</div>
<div>
	<a href="http://www.codelast.com/?p=299" rel="noopener noreferrer" target="_blank">Language Guide中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&#160;</div>
<div>
	<a href="http://www.codelast.com/?p=305" rel="noopener noreferrer" target="_blank">Style Guide中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&#160;</div>
<div>
	<a href="http://www.codelast.com/?p=316" rel="noopener noreferrer" target="_blank">Techniques 中文翻译（Google Protocol Buffers中文教程）</a>
<div>
<span id="more-8"></span>		<br />
		下面是我使用Google Protocol Buffers的一些总结：
<p>		<a href="http://www.codelast.com/?p=8519" rel="noopener noreferrer" target="_blank">Protocol Buffers的Emacs语法高亮</a></p></div>
</div>
<p>
	&#160;</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&#160;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" />&#8230; <a href="https://www.codelast.com/google-protocol-buffers%e4%b8%ad%e6%96%87%e6%95%99%e7%a8%8b/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	注：前面这些是本人的翻译，可能不准确，可能有错误，但是基本上可以理解，希望能对大家有所帮助。</p>
<div>
	<a href="http://www.codelast.com/?p=280" rel="noopener noreferrer" target="_blank">Protocol Buffer Basics: C++中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&nbsp;</div>
<div>
	<a href="http://www.codelast.com/?p=299" rel="noopener noreferrer" target="_blank">Language Guide中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&nbsp;</div>
<div>
	<a href="http://www.codelast.com/?p=305" rel="noopener noreferrer" target="_blank">Style Guide中文翻译（Google Protocol Buffers中文教程）</a></div>
<div>
	&nbsp;</div>
<div>
	<a href="http://www.codelast.com/?p=316" rel="noopener noreferrer" target="_blank">Techniques 中文翻译（Google Protocol Buffers中文教程）</a></p>
<div>
<span id="more-8"></span>		<br />
		下面是我使用Google Protocol Buffers的一些总结：</p>
<p>		<a href="http://www.codelast.com/?p=8519" rel="noopener noreferrer" target="_blank">Protocol Buffers的Emacs语法高亮</a></div>
</div>
<p>
	&nbsp;</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/google-protocol-buffers%e4%b8%ad%e6%96%87%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] log4cxx在Linux下的安装、使用</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-log4cxx%e5%9c%a8linux%e4%b8%8b%e7%9a%84%e5%ae%89%e8%a3%85%e3%80%81%e4%bd%bf%e7%94%a8/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-log4cxx%e5%9c%a8linux%e4%b8%8b%e7%9a%84%e5%ae%89%e8%a3%85%e3%80%81%e4%bd%bf%e7%94%a8/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 06:26:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[-lexpat]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[apr]]></category>
		<category><![CDATA[apr-util]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[http://logging.apache.org/log4cxx/]]></category>
		<category><![CDATA[log4c]]></category>
		<category><![CDATA[log4cxx]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[properties文件]]></category>
		<category><![CDATA[RedHat]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[undefined reference]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[安装]]></category>
		<category><![CDATA[格式]]></category>
		<category><![CDATA[编译]]></category>
		<category><![CDATA[配置文件]]></category>
		<category><![CDATA[问题]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=3211</guid>

					<description><![CDATA[<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">简单地说，log4cxx就是一个记录日志的C++库（程序运行的时候要保存一些日志到文件，以供将来查看），它是从著名的Java日志库log4j移植而来的，并且它是Apache的一个项目，质量有保证，不用犹豫了，就用它吧！</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">补一句：Apache声称log4cxx的速度快、灵活性好，但是，速度快是第一位的，灵活性是第二位的（&#34;<span style="color:#800080;">Log4cxx claims to be fast and flexible: speed first, flexibility second.</span>&#34;），所以，担心日志记录性能的同学更可以选择log4cxx啦。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">但是，这玩意的安装、编译稍微有点麻烦，如果遇到了问题，没耐心的人可能就没兴趣折腾了，我在这里把自己遇到的问题记一下。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">系统环境：RHEL 5.3，64位</span></span></span></p>
<p>
	&#160;</p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span id="more-3211"></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">首先去log4cxx的官方网站下载源码安装包：<a href="http://logging.apache.org/log4cxx/" target="_blank" rel="noopener noreferrer">http://logging.apache.org/log4cxx/</a>，点击左边的&#8220;Download&#8221;进入下载页面，当前（2011年8月9日）的最新版本是0.10.0，你可以下载 .tar.gz 压缩包，解压出来即可。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">然后就可以直接configure，make，make install了吗？不行，因为log4cxx官方提供的源码安装包不是一个all-in-one的包，它还依赖于Apache的另外两个库：Apache Portable Runtime（APR）和Apache Portable Runtime Utility（APR-Util），你可以在这个链接找到它们：<a href="http://apr.apache.org/" target="_blank" rel="noopener noreferrer">http://apr.apache.org/</a>。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">（1）安装</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">安装顺序不能变。首先要安装APR，下载到源码安装包后，解压出来，然后：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
./configure --prefix=/usr/local/apr
make
make install
</pre>
<p><span style="font-size: 14px; ">这里把APR安装到了 /usr/local/apr 目录下，注意，千万不要直接./configure，因为那样会把APR的文件安装到若干目录下，非常不利于维护。</span>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-log4cxx%e5%9c%a8linux%e4%b8%8b%e7%9a%84%e5%ae%89%e8%a3%85%e3%80%81%e4%bd%bf%e7%94%a8/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">简单地说，log4cxx就是一个记录日志的C++库（程序运行的时候要保存一些日志到文件，以供将来查看），它是从著名的Java日志库log4j移植而来的，并且它是Apache的一个项目，质量有保证，不用犹豫了，就用它吧！</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">补一句：Apache声称log4cxx的速度快、灵活性好，但是，速度快是第一位的，灵活性是第二位的（&quot;<span style="color:#800080;">Log4cxx claims to be fast and flexible: speed first, flexibility second.</span>&quot;），所以，担心日志记录性能的同学更可以选择log4cxx啦。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">但是，这玩意的安装、编译稍微有点麻烦，如果遇到了问题，没耐心的人可能就没兴趣折腾了，我在这里把自己遇到的问题记一下。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">系统环境：RHEL 5.3，64位</span></span></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span id="more-3211"></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">首先去log4cxx的官方网站下载源码安装包：<a href="http://logging.apache.org/log4cxx/" target="_blank" rel="noopener noreferrer">http://logging.apache.org/log4cxx/</a>，点击左边的&ldquo;Download&rdquo;进入下载页面，当前（2011年8月9日）的最新版本是0.10.0，你可以下载 .tar.gz 压缩包，解压出来即可。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">然后就可以直接configure，make，make install了吗？不行，因为log4cxx官方提供的源码安装包不是一个all-in-one的包，它还依赖于Apache的另外两个库：Apache Portable Runtime（APR）和Apache Portable Runtime Utility（APR-Util），你可以在这个链接找到它们：<a href="http://apr.apache.org/" target="_blank" rel="noopener noreferrer">http://apr.apache.org/</a>。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">（1）安装</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">安装顺序不能变。首先要安装APR，下载到源码安装包后，解压出来，然后：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
./configure --prefix=/usr/local/apr
make
make install
</pre>
<p><span style="font-size: 14px; ">这里把APR安装到了 /usr/local/apr 目录下，注意，千万不要直接./configure，因为那样会把APR的文件安装到若干目录下，非常不利于维护。</span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">再安装APR-Util，和上面一样，解压出来源码安装包，然后：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
</pre>
<p><span style="font-size: 14px; ">这里，通过&nbsp;--with-apr 参数指定了前一步安装的APR的目录，同时也将APR-Util的安装目录设置在了/usr/local/apr-util 目录下。</span></p>
<p style="display: inline !important; font-size: 14px;">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><font class="Apple-style-span" color="#000000">最后，就是安装log4cxx了，但是在安装之前，还要再注意一点：configure的时候要指定APR和APR-Util的安装路径：</font></span></span></p>
<p></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
mv libtool libtool.bak
ln -s /usr/bin/libtool libtool
make 
make install
</pre>
<p><span style="font-size: 14px; ">注意，中间有两条匪夷所思的命令（mv 和 ln -s），如果不执行的话，会报错（我不太记得是在configure的时候还是make的时候报的错了）：</span></p>
<blockquote>
<p>
		<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/usr/lib/libexpat.so: could not read symbols: File in wrong format</font><br />
		</span></span></span></p>
</blockquote>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">这些问题的解决办法是从网上搜来的，官方的指南做得不给力啊。</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">这样就把log4cxx安装上了，然后你需要将log4cxx整合进你的程序中，我是把 log4cxx、APR、APR-Util 的三个静态库文件全部放置到我的工程目录下的某个子目录下，然后在Makefile中指定从这个目录下去寻找库文件。三个静态库名如下：liblog4cxx.a，libapr-1.a，libaprutil-1.a。</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">此外，我还将 log4cxx、APR、APR-Util 的所有头文件（.h）放置到了工程目录下。并在自己的程序中include工程目录下的这些文件。</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">然后就是在Makefile中添加上与log4cxx相关的一切东西，包括头文件路径，库文件路径等。如果你编译的时候看到与log4cxx相关的&ldquo;undefined reference ...&rdquo;的错误，那么肯定是没有找到相关的库文件或头文件，这里需要提醒你的是要添加的几个库文件参数：-llog4cxx，-lapr-1，-laprutil-1。</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;">你把上面的步骤都做好了，这个时候，你再编译你的程序，可能又会遇到以下错误（好吧，的确有点折磨人）：</span></span></span></p>
<p style="display: inline !important; font-size: 14px;">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">./lib/log4cxx/libaprutil-1.a(apr_xml.o): In function `apr_xml_parser_geterror&#39;:</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:478: undefined reference to `XML_ErrorString&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">./lib/log4cxx/libaprutil-1.a(apr_xml.o): In function `do_parse&#39;:</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:418: undefined reference to `XML_Parse&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:422: undefined reference to `XML_GetErrorCode&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">./lib/log4cxx/libaprutil-1.a(apr_xml.o): In function `cleanup_parser&#39;:</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:344: undefined reference to `XML_ParserFree&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">./lib/log4cxx/libaprutil-1.a(apr_xml.o): In function `apr_xml_parser_create&#39;:</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:381: undefined reference to `XML_ParserCreate&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:390: undefined reference to `XML_SetUserData&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:391: undefined reference to `XML_SetElementHandler&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:392: undefined reference to `XML_SetCharacterDataHandler&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">/home/log4cxx/apr-util-1.3.12/xml/apr_xml.c:404: undefined reference to `XML_SetDefaultHandler&#39;</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">collect2: ld returned 1 exit status</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#00f;"><font class="Apple-style-span">make: *** [cpsAPI] Error 1</font><br />
	</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">这些乱七八糟的东西是怎么回事？据网上的一些文章说，这是 libaprutil 的一个bug，它不会自动链接到它的依赖项，从而导致了那些错误。要解决这个问题，你在编译的时候添加 <span style="color:#f00;">-lexpat</span> 参数即可&mdash;&mdash;无论你是在Makefile中，还是在命令行直接用g++命令编译程序，都必须要带上这个参数，否则就会得到上面的那一堆错误（真让人恼火啊）。</font></span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">这样，总算全部搞定了，程序可以编译通过了，下面，就是如何使用log4cxx来写日志的问题了，简单地说一下。在你需要写日志的类的文件中（例如MyClass.cpp），include两个log4cxx头文件：<span style="color:#00f;">log4cxx.h</span>和<span style="color:#00f;">propertyconfigurator.h</span>，然后在类的外部添加：</font></span></span></span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(&quot;MyClass.cpp&quot;));
</pre>
<p><span style="font-size: 14px; ">然后在需要写日志之前，先加载log4cxx的配置文件（其实也可以不使用配置文件的，这里假设你要使用自定义的配置文件）：</span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
log4cxx::PropertyConfigurator::configure(&quot;./log4cxx.properties&quot;);
</pre>
<p><span style="font-size: 14px; "><span style="font-size:14px;"><span style="font-family:微软雅黑;"><font class="Apple-style-span">这里指定了log4cxx.properties文件作为log4cxx的配置文件（文件名不一定是要叫log4cxx.properties），</font></span></span> </span></p>
<p style="display: inline !important; ">
	<span style="font-size: 14px; "><span style="font-size:14px;"><font class="Apple-style-span">在这个文件中定义了各种参数，例如日志文件会写到哪里去，日志的格式等等。具体的格式可以很复杂、功能很强大，这里无法给出一个详细的说明，后面会给出一个简单的文件示例。</font></span></span></p>
<p>
	<span style="font-size: 14px; "><span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#000;"><font class="Apple-style-span">然后就可以写日志了，例如：</font></span></span></span></span></p>
<p></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
LOG4CXX_INFO(logger, &quot;Test info message.&quot;);
LOG4CXX_ERROR(logger, &quot;Test error message.&quot;);
</pre>
<p><span style="font-size: 14px; color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" style="font-size: 14px; " target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></p>
<p style="display: inline !important; ">
	<span style="font-size: 14px; "><span style="font-size:14px;"><span style="font-family:微软雅黑;"><font class="Apple-style-span">运行程序，看看日志是否写进去了？写进去的话就说明成功了。</font></span></span></span></p>
<p style="display: inline !important; ">
	<span style="font-size: 14px; "><span style="font-size:14px;"><span style="font-family:微软雅黑;"><font class="Apple-style-span">上面所说的log4cxx.properties文件，给一个例子如下：</font></span></span></span></p>
<p></p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
log4j.rootLogger=debug, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller&#39;s file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p (%F:%L) %c - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./app.log
log4j.appender.R.MaxFileSize=200KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p (%F:%L) %c - %m%n
</pre>
<p><span style="font-size: 14px; ">更多log4cxx的详细用法，可以参考log4cxx的一些官方例子：</span><a href="http://logging.apache.org/log4cxx/index.html" style="font-size: 14px; " target="_blank" rel="noopener noreferrer">http://logging.apache.org/log4cxx/index.html</a><br />
<span style="font-size: 14px; color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" style="font-size: 14px; " target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
<span style="font-size: 14px; ">附：【使用log4cxx遇到的一些问题记录】<br />
（1）<span style="color:#0000ff;">IO Exception : status code =28</span><br />
这个错误可能是由于磁盘空间满了造成的，log4cxx无法将日志写入磁盘上，请看<a href="http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg02811.html" target="_blank" rel="noopener noreferrer">这个链接</a>。</span></p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPlain.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-log4cxx%e5%9c%a8linux%e4%b8%8b%e7%9a%84%e5%ae%89%e8%a3%85%e3%80%81%e4%bd%bf%e7%94%a8/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] something about Google Test(Google C++ Testing Framework)</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 14 Sep 2010 03:57:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[cxxtest]]></category>
		<category><![CDATA[Framework)]]></category>
		<category><![CDATA[Google Mock]]></category>
		<category><![CDATA[Google Test]]></category>
		<category><![CDATA[libgtest]]></category>
		<category><![CDATA[No such file or directory]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[介绍]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[注意事项]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=239</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">先说说cxxtest这个测试框架：用cxxtest来编写测试用例时，我们需要写的只是一个.h文件，在这个文件里include你要测试的类或函数所在的头文件，然后写各种测试函数。与该.h文件对应的.cpp文件是用cxxtest自带的一个脚本cxxtestgen.pl来生成的（脚本调用方法请看cxxtest手册），然后我们就得到了一个.h文件和一个.cpp文件，用gcc/g++编译，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span><br />
	<span id="more-239"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">使用Google Test作为你的测试框架时，有点不一样：</span></span></span><br />
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">你需要编写一个测试用例文件（例如，unittest.cpp），在这个文件里include你要测试的类或函数所在的头文件（当然也少不了 #include &#60;gtest/gtest.h&#62; ，这是Google Test必需的），然后在里面写各种测试，写完之后，你还再需要写一个含有main()函数的文件，例如main.cpp，内容简单，如下：</span></span></span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
#include &#60;gtest/gtest.h&#62;

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&#38;argc, argv);
  return RUN_ALL_TESTS();
}
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">有点乱了，理一下：现在共有4个文件：main.cpp，unittest.cpp，以及你需要测试的类的.h文件及.cpp文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">然后，用gcc/g++编译链接这些文件，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">注意：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（1）安装好Google Test 之后，用它编写了测试用例，可能会发现运行不了测试用例，提示&#8220;error while loading shared libraries: libgtest.so.0: cannot open shared object file: No such file or directory&#8221;，那么你就要检查一下Google Test动态库的安装路径了，例如我的RHEL5默认就是安装在 /usr/local/lib/ 下的，这个时候，你需要copy一份同样的文件在 /usr/lib/ 下，当然更简单的方法是做一个符号链接（即&#8220;快捷方式&#8221;）：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
cd /usr/lib/
ln -s /usr/local/lib/libgtest.so.0.0.0</pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">先说说cxxtest这个测试框架：用cxxtest来编写测试用例时，我们需要写的只是一个.h文件，在这个文件里include你要测试的类或函数所在的头文件，然后写各种测试函数。与该.h文件对应的.cpp文件是用cxxtest自带的一个脚本cxxtestgen.pl来生成的（脚本调用方法请看cxxtest手册），然后我们就得到了一个.h文件和一个.cpp文件，用gcc/g++编译，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span><br />
	<span id="more-239"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">使用Google Test作为你的测试框架时，有点不一样：</span></span></span><br />
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">你需要编写一个测试用例文件（例如，unittest.cpp），在这个文件里include你要测试的类或函数所在的头文件（当然也少不了 #include &lt;gtest/gtest.h&gt; ，这是Google Test必需的），然后在里面写各种测试，写完之后，你还再需要写一个含有main()函数的文件，例如main.cpp，内容简单，如下：</span></span></span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
#include &lt;gtest/gtest.h&gt;

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&amp;argc, argv);
  return RUN_ALL_TESTS();
}
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">有点乱了，理一下：现在共有4个文件：main.cpp，unittest.cpp，以及你需要测试的类的.h文件及.cpp文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">然后，用gcc/g++编译链接这些文件，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">注意：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（1）安装好Google Test 之后，用它编写了测试用例，可能会发现运行不了测试用例，提示&ldquo;error while loading shared libraries: libgtest.so.0: cannot open shared object file: No such file or directory&rdquo;，那么你就要检查一下Google Test动态库的安装路径了，例如我的RHEL5默认就是安装在 /usr/local/lib/ 下的，这个时候，你需要copy一份同样的文件在 /usr/lib/ 下，当然更简单的方法是做一个符号链接（即&ldquo;快捷方式&rdquo;）：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
cd /usr/lib/
ln -s /usr/local/lib/libgtest.so.0.0.0 libgtest.so.0
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（2）编译Google Test 自带的sample的时候，有几个注意事项：你除了要带上 -lgtest 选项，还要带上 -lpthread 选项（似乎不搭边的，不过如果不带的话，会提示几个错误），例如，我编译sample1的命令为：</span></span></span><br />
	<span style="color:#0000ff;">gcc -o sample1_exec sample1.cc sample1_unittest.cc main.cpp -lgtest -lpthread</span></p>
<p>	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">其中，sample1_exec 是生成的可执行文件名，sample1.cc 相当于我上面所说的你需要测试的类的.cpp文件，sample1_unittest.cc 相当于我上面所说的&nbsp;unittest.cpp 文件，main.cpp 就是上面所说的 main.cpp 文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">编译完成后，执行 sample1_exec，输出如下结果，测试通过：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
[       OK ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (1 ms total)
[----------] 3 tests from IsPrimeTest
[ RUN      ] IsPrimeTest.Negative
[       OK ] IsPrimeTest.Negative (0 ms)
[ RUN      ] IsPrimeTest.Trivial
[       OK ] IsPrimeTest.Trivial (0 ms)
[ RUN      ] IsPrimeTest.Positive
[       OK ] IsPrimeTest.Positive (0 ms)
[----------] 3 tests from IsPrimeTest (0 ms total)
[----------] Global test environment tear-down
[==========] 6 tests from 2 test cases ran. (3 ms total)
[  PASSED  ] 6 tests.
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color: rgb(0, 0, 0); "><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">总结：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">cxxtest是用脚本帮你生成测试含main()的.cpp文件，Google Test是你自己写含main()的.cpp文件（其实也是固定的内容），相比之下，哪个都不算麻烦。关键是，Google Test是与</span></span></span><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;"><a href="http://code.google.com/p/googlemock/" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-decoration: none; color: rgb(0, 77, 153); "><span style="color:#000000;">Google Mock</span></a><span style="color:#000000;">&ldquo;无缝结合&rdquo;的，如果你要用</span><a href="http://code.google.com/p/googlemock/" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-decoration: none; color: rgb(0, 77, 153); "><span style="color:#000000;">Google Mock</span></a></span></span><span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">，那么就最好选择Google Test了（Google Mock也可以与cxxtest联合使用，请看Google Mock的文档）。</span></span></span></p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#ffffff;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">文章来源：http://www.codelast.com/</span></span></span></p>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>CTrueColorToolBar的使用</title>
		<link>https://www.codelast.com/ctruecolortoolbar%e7%9a%84%e4%bd%bf%e7%94%a8/</link>
					<comments>https://www.codelast.com/ctruecolortoolbar%e7%9a%84%e4%bd%bf%e7%94%a8/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 14 Sep 2010 02:21:34 +0000</pubDate>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[CTrueColorToolBar]]></category>
		<category><![CDATA[VC]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[工具条]]></category>
		<category><![CDATA[工具栏]]></category>
		<category><![CDATA[用法]]></category>
		<category><![CDATA[真彩色]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=44</guid>

					<description><![CDATA[<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	这是一个真彩工具条类。使用步骤：</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（1）&#160;在MainFrm.h中加入：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-meta" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(91, 218, 237); word-wrap: inherit !important; word-break: inherit !important;">#<span class="hljs-meta-keyword" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">define</span>&#160;TOOLBAR_DRAW_BUTTON_WIDTH&#160;32&#160;&#160;&#160;&#160;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//定义真彩工具条宽度
</span></span><span class="hljs-meta" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(91, 218, 237); word-wrap: inherit !important; word-break: inherit !important;">#<span class="hljs-meta-keyword" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">include</span>&#160;&#8221;.UITrueColorToolBar.h&#8221;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//真彩工具条支持类</span></span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
<span id="more-44"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（2）在MainFrm.h中将这一句注释掉：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//CToolBar&#160;&#160;&#160;&#160;m_wndToolBar;&#160;&#160;&#160;&#160;//这一句是系统生成的</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	加上：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">CTrueColorToolBar&#160;m_wndToolBar;&#160;&#160;&#160;&#160;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//修改为真彩工具条对象</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（3）在MainFrm.cpp中，将以下部分注释掉：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*VC原来生成的
if&#160;(!m_wndToolBar.CreateEx(this,&#160;TBSTYLE_FLAT,&#160;WS_CHILD&#160;&#124;&#160;WS_VISIBLE&#160;&#124;&#160;CBRS_TOP
&#124;&#160;CBRS_GRIPPER&#160;&#124;&#160;CBRS_TOOLTIPS&#160;&#124;&#160;CBRS_FLYBY&#160;&#124;&#160;CBRS_SIZE_DYNAMIC)&#160;&#124;&#124;
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))&#160;{
&#160;&#160;TRACE0(&#8220;Failed&#160;to&#160;create&#160;toolbar&#160;&#8220;);
&#160;&#160;return&#160;-1;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;fail&#160;to&#160;create
}
*/

</span>

<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//&#160;<span class="hljs-doctag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">TODO:</span>&#160;Delete&#160;these&#160;three&#160;lines&#160;if&#160;you&#160;don&#8217;t&#160;want&#160;the&#160;toolbar&#160;to&#160;be&#160;dockable
</span>
<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*VC原来生成的
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&#38;m_wndToolBar);
*/</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	添加上以下代码：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*为真彩工具条添加的代码*/</span>
m_wndToolBar.SetBorders(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>);&#160;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//Fix&#160;for&#160;WinXP
</span>
<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">if</span>&#160;(!m_wndToolBar.Create(</code></pre>&#8230; <a href="https://www.codelast.com/ctruecolortoolbar%e7%9a%84%e4%bd%bf%e7%94%a8/" class="read-more">Read More </a></section>]]></description>
										<content:encoded><![CDATA[<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	这是一个真彩工具条类。使用步骤：</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（1）&nbsp;在MainFrm.h中加入：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-meta" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(91, 218, 237); word-wrap: inherit !important; word-break: inherit !important;">#<span class="hljs-meta-keyword" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">define</span>&nbsp;TOOLBAR_DRAW_BUTTON_WIDTH&nbsp;32&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//定义真彩工具条宽度
</span></span><span class="hljs-meta" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(91, 218, 237); word-wrap: inherit !important; word-break: inherit !important;">#<span class="hljs-meta-keyword" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">include</span>&nbsp;&rdquo;.UITrueColorToolBar.h&rdquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//真彩工具条支持类</span></span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
<span id="more-44"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（2）在MainFrm.h中将这一句注释掉：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//CToolBar&nbsp;&nbsp;&nbsp;&nbsp;m_wndToolBar;&nbsp;&nbsp;&nbsp;&nbsp;//这一句是系统生成的</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	加上：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">CTrueColorToolBar&nbsp;m_wndToolBar;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//修改为真彩工具条对象</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（3）在MainFrm.cpp中，将以下部分注释掉：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*VC原来生成的
if&nbsp;(!m_wndToolBar.CreateEx(this,&nbsp;TBSTYLE_FLAT,&nbsp;WS_CHILD&nbsp;|&nbsp;WS_VISIBLE&nbsp;|&nbsp;CBRS_TOP
|&nbsp;CBRS_GRIPPER&nbsp;|&nbsp;CBRS_TOOLTIPS&nbsp;|&nbsp;CBRS_FLYBY&nbsp;|&nbsp;CBRS_SIZE_DYNAMIC)&nbsp;||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))&nbsp;{
&nbsp;&nbsp;TRACE0(&ldquo;Failed&nbsp;to&nbsp;create&nbsp;toolbar&nbsp;&ldquo;);
&nbsp;&nbsp;return&nbsp;-1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;fail&nbsp;to&nbsp;create
}
*/

</span>

<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//&nbsp;<span class="hljs-doctag" style="font-size: inherit; color: inherit; line-height: inherit; margin: 0px; padding: 0px; word-wrap: inherit !important; word-break: inherit !important;">TODO:</span>&nbsp;Delete&nbsp;these&nbsp;three&nbsp;lines&nbsp;if&nbsp;you&nbsp;don&rsquo;t&nbsp;want&nbsp;the&nbsp;toolbar&nbsp;to&nbsp;be&nbsp;dockable
</span>
<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*VC原来生成的
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&amp;m_wndToolBar);
*/</span></code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	添加上以下代码：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="c++ language-c++ hljs cpp" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">/*为真彩工具条添加的代码*/</span>
m_wndToolBar.SetBorders(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>,&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>);&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//Fix&nbsp;for&nbsp;WinXP
</span>
<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">if</span>&nbsp;(!m_wndToolBar.Create(<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">this</span>,&nbsp;WS_CHILD&nbsp;|
WS_VISIBLE&nbsp;|&nbsp;CBRS_TOP&nbsp;|&nbsp;CBRS_GRIPPER&nbsp;|
CBRS_TOOLTIPS&nbsp;|&nbsp;CBRS_FLYBY&nbsp;|&nbsp;CBRS_SIZE_DYNAMIC)&nbsp;||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))&nbsp;{
&nbsp;&nbsp;TRACE0(&ldquo;Failed&nbsp;to&nbsp;create&nbsp;toolbar&nbsp;&ldquo;);
&nbsp;&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">return</span>&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">-1</span>;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//Failed&nbsp;to&nbsp;create</span>
}
m_wndToolBar.ModifyStyle(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">0</span>,&nbsp;TBSTYLE_FLAT);&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//Fix&nbsp;for&nbsp;WinXP</span>
m_wndToolBar.LoadTrueColorToolBar(TOOLBAR_DRAW_BUTTON_WIDTH,&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(128, 128, 128); word-wrap: inherit !important; word-break: inherit !important;">//加载真彩工具条</span>
IDB_BITMAP_NORMAL,
IDB_BITMAP_HOT,
IDB_BITMAP_DISABLE);
</code></pre>
</section>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	其中，&nbsp;IDB_BITMAP_NORMAL&nbsp;是正常状态的工具条，IDB_BITMAP_HOT&nbsp;是鼠标移动到上面时的工具条，IDB_BITMAP_DISABLE&nbsp;是被禁止状态的工具条。这是三个位图（bmp）文件，需要你事先制作好，并导入VC工程的资源中。此外还要注意：你在VC工程的资源里原先的Toolbar尺寸必须调整得与上面代码中的&nbsp;TOOLBAR_DRAW_BUTTON_WIDTH&nbsp;的值保持一致，否则显示的时候会出问题。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p>
	（4）OK，编译运行。效果如下所示：<a href="http://www.codelast.com/wp-content/uploads/2010/09/Toolbar.jpg"><img decoding="async" alt="工具条" class="alignnone size-full wp-image-45" height="61" src="http://www.codelast.com/wp-content/uploads/2010/09/Toolbar.jpg" title="Toolbar" width="470" srcset="https://www.codelast.com/wp-content/uploads/2010/09/Toolbar.jpg 470w, https://www.codelast.com/wp-content/uploads/2010/09/Toolbar-300x38.jpg 300w" sizes="(max-width: 470px) 100vw, 470px" /></a></p>
<p>
	<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/ctruecolortoolbar%e7%9a%84%e4%bd%bf%e7%94%a8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
