﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Networking /C++/Linux-文章分类-Linux environment programming</title><link>http://www.cppblog.com/lk624424108/category/18341.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 04 Jan 2012 02:53:47 GMT</lastBuildDate><pubDate>Wed, 04 Jan 2012 02:53:47 GMT</pubDate><ttl>60</ttl><item><title>libevent example</title><link>http://www.cppblog.com/lk624424108/articles/162909.html</link><dc:creator>likun</dc:creator><author>likun</author><pubDate>Tue, 27 Dec 2011 06:20:00 GMT</pubDate><guid>http://www.cppblog.com/lk624424108/articles/162909.html</guid><wfw:comment>http://www.cppblog.com/lk624424108/comments/162909.html</wfw:comment><comments>http://www.cppblog.com/lk624424108/articles/162909.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lk624424108/comments/commentRss/162909.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lk624424108/services/trackbacks/162909.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;这篇文章介绍下libevent在socket异步编程中的应用。在一些对性能要求较高的网络应用程序中，为了防止程序阻塞在socket I/O操作上造成程序性能的下降，需要使用异步编程，即程序准备好读写的函数(或接口)并向系统注册，然后在需要的时候只向系统提交读写的请求之后就继续做自己的事情，实际的读写操作由系统在合适的时候调用我们程序注册的接口进行。异步编程会给一些程序猿带来一些理解和编...&nbsp;&nbsp;<a href='http://www.cppblog.com/lk624424108/articles/162909.html'>阅读全文</a><img src ="http://www.cppblog.com/lk624424108/aggbug/162909.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lk624424108/" target="_blank">likun</a> 2011-12-27 14:20 <a href="http://www.cppblog.com/lk624424108/articles/162909.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编程语言的选择</title><link>http://www.cppblog.com/lk624424108/articles/162665.html</link><dc:creator>likun</dc:creator><author>likun</author><pubDate>Fri, 23 Dec 2011 04:06:00 GMT</pubDate><guid>http://www.cppblog.com/lk624424108/articles/162665.html</guid><wfw:comment>http://www.cppblog.com/lk624424108/comments/162665.html</wfw:comment><comments>http://www.cppblog.com/lk624424108/articles/162665.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lk624424108/comments/commentRss/162665.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lk624424108/services/trackbacks/162665.html</trackback:ping><description><![CDATA[<div><p style="line-height: 25px; text-align: left; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; ">你愿意学习新的编程语言吗？你愿意置身于一个全新的应用开发世界里吗？那就赶快选择一门编程语言开始学习吧！也许在几年后，你就能依靠学习的积累独立开发出应用程序。但在此之前，你要先做足事前准备。</p><p style="line-height: 25px; text-align: left; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; ">在多如牛毛的编程语言世界中，选择语言也是一门很重要的功课。如何在大量的语言中选择呢？这里将为你提供一个实用指南。</p><p style="line-height: 25px; text-align: center; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; "><img width="523" border="0" height="2032" alt="" src="http://articles.csdn.net/uploads/allimg/111125/89_111125164851_1.png" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; cursor: pointer; " /></p><p style="line-height: 25px; text-align: left; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; ">&nbsp;</p><p style="line-height: 25px; text-align: left; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; ">我花费七周的时间读了七种编程语言后做出了这个流程图表。我发现在选择编程语言的结果中，有一部分是创业的开发者，他们为了创业而尝试学习新的语言放下原来的语言。所以，这也是你的机会，赶快选择和学习吧！</p><p style="line-height: 25px; text-align: left; font-family: Helvetica, Tahoma, Arial, sans-serif; background-color: #f8fafd; ">原文链接：<a href="http://www.streamhead.com/what-programming-language-to-learn-next/" style="color: #015fb6; text-decoration: none; ">streamhead.com<br /><div><a href="http://news.csdn.net/a/20111125/308161.html?bsh_bid=55911993">http://news.csdn.net/a/20111125/308161.html?bsh_bid=55911993</a></div></a></p></div><img src ="http://www.cppblog.com/lk624424108/aggbug/162665.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lk624424108/" target="_blank">likun</a> 2011-12-23 12:06 <a href="http://www.cppblog.com/lk624424108/articles/162665.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Makefile Libtool  Automake</title><link>http://www.cppblog.com/lk624424108/articles/162427.html</link><dc:creator>likun</dc:creator><author>likun</author><pubDate>Mon, 19 Dec 2011 14:47:00 GMT</pubDate><guid>http://www.cppblog.com/lk624424108/articles/162427.html</guid><wfw:comment>http://www.cppblog.com/lk624424108/comments/162427.html</wfw:comment><comments>http://www.cppblog.com/lk624424108/articles/162427.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lk624424108/comments/commentRss/162427.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lk624424108/services/trackbacks/162427.html</trackback:ping><description><![CDATA[<div><h2><a id="ctl01_TitleUrl" href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #223355; text-decoration: none; ">用automake建立共享库(动态链接库)Makefile</a></h2><div style="background-color: #ffffff; "><div id="cnblogs_post_body"><p style="font-family: Arial; line-height: 25px; ">要使用automake工具包建立一个交叉编译的共享库的Makefile</p><p style="font-family: Arial; line-height: 25px; ">这里用的autoconf是2.67版本，在debian下实现:</p><p style="font-family: Arial; line-height: 25px; ">如果版本低，可以用apt-get install automake来装最新的版本，还需要libtool,也需要用apt-get install来安装。</p><p style="font-family: Arial; line-height: 25px; ">这里建立一个简单的函数库来介绍：</p><p style="font-family: Arial; line-height: 25px; ">建立目录rx,及源码目录src:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; color: #0000ff; ">mkdir</span><span style="line-height: 1.5; "> rx<br /></span><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; color: #0000ff; ">mkdir</span><span style="line-height: 1.5; "> rx</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">src</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">在rx/src下编辑rx.c,rx.h两个源文件:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">mybdebian:</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">home</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">myb</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">php</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">rx</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">src</span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; "> cat rx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">h<br /></span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; ">ifndef __RX_H_<br /></span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; ">define __RX_H_<br />int fun</span><span style="line-height: 1.5; ">();</span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; ">endif<br />mybdebian:</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">home</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">myb</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">php</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">rx</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">src</span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; "> cat rx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">c<br /></span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; ">include </span><span style="line-height: 1.5; ">"</span><span style="line-height: 1.5; ">rx.h</span><span style="line-height: 1.5; ">"</span><span style="line-height: 1.5; "><br />int fun</span><span style="line-height: 1.5; ">()</span><span style="line-height: 1.5; "><br />{<br />    </span><span style="line-height: 1.5; color: #0000ff; ">return</span> <span style="line-height: 1.5; ">1234</span><span style="line-height: 1.5; ">;</span><span style="line-height: 1.5; "><br />}</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">在rx目录和rx/src目录下分别建立Makefile.am文件</p><p style="font-family: Arial; line-height: 25px; ">rx目录下的Makefile.am为顶层Makefile.am文件，只要包含其存放源码的子目录即可，内容如下：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AUTOMAKE_OPTIONS</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">foreign<br />SUBDIRS</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">src</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">rx/src目录下的Makefile.am内容如下：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AUTOMAKE_OPTIONS</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">foreign<br />lib_LTLIBRARIES</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">librx.la<br />librx_la_SOURCES</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">rx.c</span></div><div><span style="line-height: 1.5; ">include_HEADERS=rx.h</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">其中lib_LTLIBRARIES=后面的&#8220;librx.la&#8221;为要生成的库文件名,必须写成.la，不能是.so，实际会生成librx.so文件。</p><p style="font-family: Arial; line-height: 25px; ">下面的librx_la是librx.la把&#8220;.&#8221;换成下划线&#8220;_&#8221;后面加上&#8220;_SOURCES=&#8221;，等号以后为源文件名称，多于一个时用空格隔开。</p><p style="font-family: Arial; line-height: 25px; ">include_HEADERS=后面的为头文件，是供其它程序包含用的，make install时会复制到安装目录的include 目录中。</p><p style="font-family: Arial; line-height: 25px; ">回到上层目录，使用autoscan扫描源码目录:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; color: #800080; ">$autoscan</span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #800080; ">$ls</span><span style="line-height: 1.5; "><br />autoscan.log  configure.scan  Makefile.am  src</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">把configure.scan改名成为configure.ac</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; color: #800080; ">$mv</span><span style="line-height: 1.5; "> configure.scan configure.ac</span></div></pre></div><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AC_OUTPUT([Makefile<br />                 src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">Makefile])</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">编译这个文件:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">vim configure</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">ac</span></div></pre></div><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; ">                                               -*- Autoconf -*-</span><span style="line-height: 1.5; color: #008000; "><br />#</span><span style="line-height: 1.5; color: #008000; "> Process this file with autoconf to produce a configure script.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br />AC_PREREQ([</span><span style="line-height: 1.5; ">2.67</span><span style="line-height: 1.5; ">])<br />AC_INIT([FULL</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">PACKAGE</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">NAME], [VERSION], [BUG</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">REPORT</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">ADDRESS])<br />AC_CONFIG_SRCDIR([src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">rx.c])<br />AC_CONFIG_HEADERS([config.h])<br /><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for programs.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; ">AC_PROG_CC<br /><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for libraries.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for header files.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for typedefs, structures, and compiler characteristics.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for library functions.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br />AC_CONFIG_FILES([Makefile<br />                 src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">Makefile])<br />AC_OUTPUT</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">修改AC_INIT一句，即把包的全名、版本号及BUG报告email地址添上，如：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AC_INIT(rx2dlib,</span><span style="line-height: 1.5; ">0.01</span><span style="line-height: 1.5; ">,resound</span><span style="line-height: 1.5; ">@</span><span style="line-height: 1.5; ">163</span><span style="line-height: 1.5; ">.com)</span></div></pre></div><p style="font-family: Arial; line-height: 25px; ">在它后面加一句:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AM_INIT_AUTOMAKE</span></div></pre></div><p style="font-family: Arial; line-height: 25px; ">这句话是必须的。</p><p style="font-family: Arial; line-height: 25px; ">由于这个脚本是用于生成共享库的，所以要加一句AC_PROG_LIBTOOL在AC_PROG_CC的下一行：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for programs.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; ">AC_PROG_CC<br />AC_PROG_LIBTOOL</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">修改后面的那个AC_CONFIG_FILES语句，改成AC_OUTPUT,并把后面的一条AC_OUTPUT去掉：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">AC_OUTPUT([Makefile<br />                 src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">Makefile])</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">这样，configure.ac就建好了，修改后的内容如下:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; ">                                               -*- Autoconf -*-</span><span style="line-height: 1.5; color: #008000; "><br />#</span><span style="line-height: 1.5; color: #008000; "> Process this file with autoconf to produce a configure script.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br />AC_PREREQ([</span><span style="line-height: 1.5; ">2.67</span><span style="line-height: 1.5; ">])<br />AC_INIT(rx2dlib,</span><span style="line-height: 1.5; ">0.01</span><span style="line-height: 1.5; ">,resound</span><span style="line-height: 1.5; ">@</span><span style="line-height: 1.5; ">163</span><span style="line-height: 1.5; ">.com)<br />AM_INIT_AUTOMAKE<br /><br />AC_CONFIG_SRCDIR([src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">rx.c])<br />AC_CONFIG_HEADERS([config.h])<br /><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for programs.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; ">AC_PROG_CC<br />AC_PROG_LIBTOOL<br /><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for libraries.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for header files.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for typedefs, structures, and compiler characteristics.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br /></span><span style="line-height: 1.5; color: #008000; ">#</span><span style="line-height: 1.5; color: #008000; "> Checks for library functions.</span><span style="line-height: 1.5; color: #008000; "><br /></span><span style="line-height: 1.5; "><br />AC_OUTPUT([Makefile<br />                 src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">Makefile])</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">然后按顺序执行:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">aclocal<br /></span><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">autoconf<br /></span><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">autoheader<br /></span><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">libtoolize --automake<br /></span><span style="line-height: 1.5; ">$</span><span style="line-height: 1.5; ">automake &#8211;-add-missing<br />configure</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">ac:</span><span style="line-height: 1.5; ">13</span><span style="line-height: 1.5; ">: installing `</span><span style="line-height: 1.5; ">./</span><span style="line-height: 1.5; ">config</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">guess'<br />configure</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">ac:</span><span style="line-height: 1.5; ">13</span><span style="line-height: 1.5; ">: installing `</span><span style="line-height: 1.5; ">./</span><span style="line-height: 1.5; ">config</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">sub'<br />configure</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">ac:</span><span style="line-height: 1.5; ">6</span><span style="line-height: 1.5; ">: installing `</span><span style="line-height: 1.5; ">./</span><span style="line-height: 1.5; ">install-sh'<br />configure</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">ac:</span><span style="line-height: 1.5; ">6</span><span style="line-height: 1.5; ">: installing `</span><span style="line-height: 1.5; ">./</span><span style="line-height: 1.5; ">missing'<br />src</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">Makefile</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">am: installing `</span><span style="line-height: 1.5; ">./</span><span style="line-height: 1.5; ">depcomp'</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">这时configure脚本已经生成了。</p><p style="font-family: Arial; line-height: 25px; ">可以用它来配置生成Makefile了。</p><p style="font-family: Arial; line-height: 25px; ">如我们要生成交叉编译给ARM CPU使用的共享库,这里假设我们要使用的编译器为arm-none-linux-gnueabi-gcc，并且我们最终在ARM板上执行时，要把库安装到目标板的/usr/local/armrx2d目录中去。可以这样配置:</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">$./</span><span style="line-height: 1.5; ">configure  --host</span><span style="line-height: 1.5; ">=</span><span style="line-height: 1.5; ">arm-none-linux-gnueabi --prefix</span><span style="line-height: 1.5; ">=/</span><span style="line-height: 1.5; ">usr</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">local</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">armrx2d</span></div><div><span style="line-height: 1.5; "><p>$make</p></span></div><div><span face="'Courier New'" style="line-height: 1.5; "><br /></span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">Make完成后可以到src目录下面的一个隐藏目录.libs目录中看到生成的库文件：</p><div style="font-family: Arial; line-height: 25px; font-size: 12px; "><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; margin-left: 22px; font-family: 'Courier New'; "><div><span style="line-height: 1.5; ">mybdebian:</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">home</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">myb</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">php</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">rx</span><span style="line-height: 1.5; ">/</span><span style="line-height: 1.5; ">src</span><span style="line-height: 1.5; ">/.</span><span style="line-height: 1.5; ">libs</span><span style="line-height: 1.5; ">#</span><span style="line-height: 1.5; "> ls -l<br />总计 </span><span style="line-height: 1.5; ">20</span><span style="line-height: 1.5; "><br />-rw-r--r-- </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root </span><span style="line-height: 1.5; ">2368</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">a<br />lrwxrwxrwx </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root   </span><span style="line-height: 1.5; ">11</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">la -</span><span style="line-height: 1.5; ">&gt;</span> <span style="line-height: 1.5; ">../</span><span style="line-height: 1.5; ">librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">la<br />-rw-r--r-- </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root  </span><span style="line-height: 1.5; ">930</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">lai<br />lrwxrwxrwx </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root   </span><span style="line-height: 1.5; ">14</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">so -</span><span style="line-height: 1.5; ">&gt;</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">so</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0.0</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0</span><span style="line-height: 1.5; "><br />lrwxrwxrwx </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root   </span><span style="line-height: 1.5; ">14</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">so</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0</span><span style="line-height: 1.5; "> -</span><span style="line-height: 1.5; ">&gt;</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">so</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0.0</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0</span><span style="line-height: 1.5; "><br />-rwxr-xr-x </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root </span><span style="line-height: 1.5; ">5422</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> librx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">so</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0.0</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">0</span><span style="line-height: 1.5; "><br />-rw-r--r-- </span><span style="line-height: 1.5; ">1</span><span style="line-height: 1.5; "> root root </span><span style="line-height: 1.5; ">2228</span> <span style="line-height: 1.5; ">04</span><span style="line-height: 1.5; ">-</span><span style="line-height: 1.5; ">19</span> <span style="line-height: 1.5; ">22</span><span style="line-height: 1.5; ">:</span><span style="line-height: 1.5; ">48</span><span style="line-height: 1.5; "> rx</span><span style="line-height: 1.5; ">.</span><span style="line-height: 1.5; ">o</span></div></pre><div style="margin-top: 5px; "><span style="padding-right: 5px; line-height: 1.5; "><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html" style="color: #1d58d1; text-decoration: none; ">复制代码</a></span></div></div><p style="font-family: Arial; line-height: 25px; ">我们再回到顶层目录，执行make install可以自动安装生成的库到/usr/local/armrx2d/lib目录下。</p><p style="font-family: Arial; line-height: 25px; ">若使用automake时出现下面错误信息</p><p style="font-family: Arial; line-height: 25px; ">required file `./ltmain.sh' not found</p><p style="font-family: Arial; line-height: 25px; ">是因为libtool未配置：</p><p style="font-family: Arial; line-height: 25px; ">解决办法：</p><p style="font-family: Arial; line-height: 25px; ">$libtoolize --automake --debug --copy &#8211;force</p><p style="font-family: Arial; line-height: 25px; ">或：</p><p><font face="Arial"><span style="line-height: 25px;">$libtoolize --automake</span></font><br /><br /></p><div><div><span style="line-height: 25px;">#</span></div><div><span style="line-height: 25px;">#</span></div><div><span style="line-height: 25px;"># 利用libtool自动生成动态库</span></div><div><span style="line-height: 25px;">#</span></div><div><span style="line-height: 25px;">1. autoscan命令在当前目录生成configure.scan文件, 内容为:</span></div><div><span style="line-height: 25px;"># -*- Autoconf -*-</span></div><div><span style="line-height: 25px;"># Process this file with autoconf to produce a configure script.</span></div><div><span style="line-height: 25px;">AC_PREREQ(2.57)</span></div><div><span style="line-height: 25px;">AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)</span></div><div><span style="line-height: 25px;">AC_CONFIG_SRCDIR([src/bot.h])</span></div><div><span style="line-height: 25px;">AC_CONFIG_HEADER([config.h])</span></div><div><span style="line-height: 25px;"># Checks for programs.</span></div><div><span style="line-height: 25px;">AC_PROG_CXX</span></div><div><span style="line-height: 25px;">AC_PROG_CC</span></div><div><span style="line-height: 25px;"># Checks for libraries.</span></div><div><span style="line-height: 25px;"># Checks for header files.</span></div><div><span style="line-height: 25px;">AC_HEADER_STDC</span></div><div><span style="line-height: 25px;">AC_CHECK_HEADERS([limits.h malloc.h stdlib.h string.h unistd.h])</span></div><div><span style="line-height: 25px;"># Checks for typedefs, structures, and compiler characteristics.</span></div><div><span style="line-height: 25px;">AC_HEADER_STDBOOL</span></div><div><span style="line-height: 25px;">AC_C_CONST</span></div><div><span style="line-height: 25px;">AC_C_INLINE</span></div><div><span style="line-height: 25px;"># Checks for library functions.</span></div><div><span style="line-height: 25px;">AC_FUNC_MALLOC</span></div><div><span style="line-height: 25px;">AC_FUNC_REALLOC</span></div><div><span style="line-height: 25px;">AC_CHECK_FUNCS([memset strcasecmp strchr strdup])</span></div><div><span style="line-height: 25px;">AC_OUTPUT</span></div><div><span style="line-height: 25px;">将其该名为configure.ac 然后修改:</span></div><div><span style="line-height: 25px;">configure.ac 文件是 autoconf 的输入文件，经过 autoconf 处理，展开里面的 m4宏，</span></div><div><span style="line-height: 25px;">输出的是 configure 脚本。</span></div><div><span style="line-height: 25px;">第 4 行声明本文件要求的 autoconf 版本，因为本例使用了新版本 2.57，所以在此注明。</span></div><div><span style="line-height: 25px;">第 5 行 AC_INIT 宏用来定义软件的名称和版本等信息</span></div><div><span style="line-height: 25px;">AC_INIT([test], 1.0, [email]linhanzu@gmail.com[/email])</span></div><div><span style="line-height: 25px;">增加版本信息(为生成lib库做准备)</span></div><div><span style="line-height: 25px;">lt_major=1</span></div><div><span style="line-height: 25px;">lt_age=1</span></div><div><span style="line-height: 25px;">lt_revision=12</span></div><div><span style="line-height: 25px;">dist_version=0.1.12</span></div><div><span style="line-height: 25px;">AM_INIT_AUTOMAKE(test, $dist_version) //自动生成Makefile文件</span></div><div><span style="line-height: 25px;">增加宏, 打开共享库</span></div><div><span style="line-height: 25px;">AC_PROG_LIBTOOL</span></div><div><span style="line-height: 25px;"># Check for dl &nbsp;</span></div><div><span style="line-height: 25px;">DL_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( dl, dlopen, DL_PRESENT="yes",, $DL_LIBS -ldl )</span></div><div><span style="line-height: 25px;">if test "x$DL_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBDL, 1, [Define if DL lib is present])</span></div><div><span style="line-height: 25px;">DL_LIBS="-ldl"</span></div><div><span style="line-height: 25px;">AC_SUBST(DL_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;"># Check for libm</span></div><div><span style="line-height: 25px;">M_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( m, sin, M_PRESENT="yes",, $M_LIBS -lm )</span></div><div><span style="line-height: 25px;">if test "x$M_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBM, 1, [Define if libm is present])</span></div><div><span style="line-height: 25px;">M_LIBS="-lm"</span></div><div><span style="line-height: 25px;">AC_SUBST(M_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;">增加依赖库，这里就仅仅列举了pthread库，生成的Makefile会自动加上-pthread</span></div><div><span style="line-height: 25px;"># Check for pthread</span></div><div><span style="line-height: 25px;">PTHREAD_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( pthread, pthread_create, PTHREAD_PRESENT="yes",, $PTHREAD_LIBS</span></div><div><span style="line-height: 25px;">-lpthread )</span></div><div><span style="line-height: 25px;">if test "x$PTHREAD_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if libpthread is present])</span></div><div><span style="line-height: 25px;">PTHREAD_LIBS="-lpthread"</span></div><div><span style="line-height: 25px;">AC_SUBST(PTHREAD_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;">要生成项目工程目录和其它目录下的Makefile 文件, 必需加入</span></div><div><span style="line-height: 25px;">AM_CONFIG_FILES的宏:</span></div><div><span style="line-height: 25px;">例如: AC_CONFIG_FILES([Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;src/Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data/Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;docs/Makefile])</span></div><div><span style="line-height: 25px;">修改完后Makefile.ac如下:</span></div><div><span style="line-height: 25px;"># -*- Autoconf -*-</span></div><div><span style="line-height: 25px;"># Process this file with autoconf to produce a configure script.</span></div><div><span style="line-height: 25px;">AC_PREREQ(2.57)</span></div><div><span style="line-height: 25px;">AC_INIT([test],[1.0],[[email]arne_caspari@users.sourceforge.net[/email]])</span></div><div><span style="line-height: 25px;">AM_CONFIG_HEADER(config.h)</span></div><div><span style="line-height: 25px;">lt_major=1</span></div><div><span style="line-height: 25px;">lt_age=1</span></div><div><span style="line-height: 25px;">lt_revision=12</span></div><div><span style="line-height: 25px;">dist_version=0.1.12</span></div><div><span style="line-height: 25px;">AM_INIT_AUTOMAKE(test, $dist_version)</span></div><div><span style="line-height: 25px;">AC_SUBST(lt_major)</span></div><div><span style="line-height: 25px;">AC_SUBST(lt_revision)</span></div><div><span style="line-height: 25px;">AC_SUBST(lt_age)</span></div><div><span style="line-height: 25px;"># Checks for programs.</span></div><div><span style="line-height: 25px;">#AC_PROG_CC</span></div><div><span style="line-height: 25px;">#AC_PROG_INSTALL</span></div><div><span style="line-height: 25px;">#AC_PROG_LN_S</span></div><div><span style="line-height: 25px;">#AC_PROG_LIBTOOL</span></div><div><span style="line-height: 25px;">AM_PROG_LIBTOOL</span></div><div><span style="line-height: 25px;"># Checks for libraries.</span></div><div><span style="line-height: 25px;">pkg_modules="gtk+-2.0 &gt;= 2.0.0"</span></div><div><span style="line-height: 25px;">PKG_CHECK_MODULES(GTK_PACKAGE, [$pkg_modules], HAVE_GTK2="yes", HAVE_GTK2="no" )</span></div><div><span style="line-height: 25px;">AC_SUBST(GTK_PACKAGE_CFLAGS)</span></div><div><span style="line-height: 25px;">AC_SUBST(GTK_PACKAGE_LIBS)</span></div><div><span style="line-height: 25px;"># Check for dl</span></div><div><span style="line-height: 25px;">DL_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( dl, dlopen, DL_PRESENT="yes",, $DL_LIBS -ldl )</span></div><div><span style="line-height: 25px;">if test "x$DL_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBDL, 1, [Define if DL lib is present])</span></div><div><span style="line-height: 25px;">DL_LIBS="-ldl"</span></div><div><span style="line-height: 25px;">AC_SUBST(DL_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;"># Check for libm</span></div><div><span style="line-height: 25px;">M_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( m, sin, M_PRESENT="yes",, $M_LIBS -lm )</span></div><div><span style="line-height: 25px;">if test "x$M_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBM, 1, [Define if libm is present])</span></div><div><span style="line-height: 25px;">M_LIBS="-lm"</span></div><div><span style="line-height: 25px;">AC_SUBST(M_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;"># Check for pthread&nbsp;</span></div><div><span style="line-height: 25px;">PTHREAD_PRESENT=""</span></div><div><span style="line-height: 25px;">AC_CHECK_LIB( pthread, pthread_create, PTHREAD_PRESENT="yes",, $PTHREAD_LIBS</span></div><div><span style="line-height: 25px;">-lpthread )</span></div><div><span style="line-height: 25px;">if test "x$PTHREAD_PRESENT" = "xyes"; then</span></div><div><span style="line-height: 25px;">AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if libpthread is present])</span></div><div><span style="line-height: 25px;">PTHREAD_LIBS="-lpthread"</span></div><div><span style="line-height: 25px;">AC_SUBST(PTHREAD_LIBS)</span></div><div><span style="line-height: 25px;">fi</span></div><div><span style="line-height: 25px;"># Checks for header files.</span></div><div><span style="line-height: 25px;">#AC_HEADER_DIRENT</span></div><div><span style="line-height: 25px;">#AC_HEADER_STDC</span></div><div><span style="line-height: 25px;">#AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h])</span></div><div><span style="line-height: 25px;"># Checks for typedefs, structures, and compiler characteristics.</span></div><div><span style="line-height: 25px;">#AC_TYPE_PID_T</span></div><div><span style="line-height: 25px;">#AC_TYPE_SIZE_T</span></div><div><span style="line-height: 25px;">#AC_HEADER_TIME</span></div><div><span style="line-height: 25px;"># Checks for library functions.</span></div><div><span style="line-height: 25px;">#AC_FUNC_CLOSEDIR_VOID</span></div><div><span style="line-height: 25px;">#AC_FUNC_MALLOC</span></div><div><span style="line-height: 25px;">#AC_CHECK_FUNCS([memset strstr])</span></div><div><span style="line-height: 25px;">AC_CONFIG_FILES([Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;src/Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data/Makefile</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doc/Makefile])</span></div><div><span style="line-height: 25px;">AC_OUTPUT</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">2.生成各目录下的Makefile.am文件</span></div><div><span style="line-height: 25px;">./Makefile.am &nbsp; //工程目录下</span></div><div><span style="line-height: 25px;">&nbsp; SUBDIR = src data doc</span></div><div><span style="line-height: 25px;">../src/Makefile.am &nbsp;//源码目录下</span></div><div><span style="line-height: 25px;">&nbsp; MAINTAINERCLEANFILES = Makefile.in</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp;INCLUDES = -I../include &nbsp;</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp;CPPFLAGS=-DINSTALL_PREFIX="\"$(prefix)\""</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp;lib_LTLIBRARIES = libtest.la</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp;libtest_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp;libtest_la_SOURCES = \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test.c \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test_private.h \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_match.c \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_match.h \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test_helpers.c \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test_helpers.h \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debug.h</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; libtest_la_LIBADD = \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DL_LIBS@ \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @M_LIBS@</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">3. 生成autogen.sh脚本, 内容</span></div><div><span style="line-height: 25px;">#! /bin/sh</span></div><div><span style="line-height: 25px;">set -x</span></div><div><span style="line-height: 25px;">aclocal</span></div><div><span style="line-height: 25px;">autoheader</span></div><div><span style="line-height: 25px;">automake --foreign --add-missing --copy</span></div><div><span style="line-height: 25px;">autoconf</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">保存后修改权限 chmod a+x autogen.sh</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">3.运行脚本./autogen.sh, 生成configure脚本. 这里可能会遇到错误, 可以根据错误提示作相应修改.（注意：如果您修改了Makefile.am中的项，那么就得重新执行这一步）</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">4.运行./configure脚本.自动生成src目录下的makefile文件</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">5. 切换到目录src, 运行make 自动在当前目录下建立.libs文件, 编程生成的库文件就保存在该目录下.</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; make install 安装在默认目录 /usr/local/lib/下.</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">6.如果要生成其它的安装目录，Makefile.am就要这样写</span></div><div><span style="line-height: 25px;">MAINTAINERCLEANFILES = Makefile.in</span></div><div><span style="line-height: 25px;">INCLUDES = -I../include&nbsp;</span></div><div><span style="line-height: 25px;">lib_LTLIBRARIES = libtt.la</span></div><div><span style="line-height: 25px;">libdir = $(prefix)/lib/test &nbsp;//这个就是安装目录</span></div><div><span style="line-height: 25px;">libtt_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@</span></div><div><span style="line-height: 25px;">libtt_la_LIBADD = @PTHREAD_LIBS@</span></div><div><span style="line-height: 25px;">libtt_la_SOURCES = \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tt.c \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.c \</span></div><div><span style="line-height: 25px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.h</span></div><div><span style="line-height: 25px;"><br /></span></div><div><span style="line-height: 25px;">当然，Makefile中的语法规则中还有很多宏定义，您可以在Makefile的官方网站找到说明。</span></div><div><span style="line-height: 25px;">下一篇就打算写写条件编译的Makefile写法。</span></div></div><br /><div><a href="http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html">http://www.cnblogs.com/resound/archive/2011/04/19/2021681.html</a></div><div><a href="http://bbs.chinaunix.net/thread-2165630-1-1.html">http://bbs.chinaunix.net/thread-2165630-1-1.html</a></div><br /><br /><br /><br /><br /><br /><p>&nbsp;</p></div></div></div><img src ="http://www.cppblog.com/lk624424108/aggbug/162427.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lk624424108/" target="_blank">likun</a> 2011-12-19 22:47 <a href="http://www.cppblog.com/lk624424108/articles/162427.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Redis 精彩文章</title><link>http://www.cppblog.com/lk624424108/articles/162035.html</link><dc:creator>likun</dc:creator><author>likun</author><pubDate>Tue, 13 Dec 2011 07:26:00 GMT</pubDate><guid>http://www.cppblog.com/lk624424108/articles/162035.html</guid><wfw:comment>http://www.cppblog.com/lk624424108/comments/162035.html</wfw:comment><comments>http://www.cppblog.com/lk624424108/articles/162035.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lk624424108/comments/commentRss/162035.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lk624424108/services/trackbacks/162035.html</trackback:ping><description><![CDATA[<a href="http://blog.nosqlfan.com/html/3537.html" title="Redis">Redis</a><img src ="http://www.cppblog.com/lk624424108/aggbug/162035.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lk624424108/" target="_blank">likun</a> 2011-12-13 15:26 <a href="http://www.cppblog.com/lk624424108/articles/162035.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vfork  产生的奇怪的现象，求解释</title><link>http://www.cppblog.com/lk624424108/articles/161833.html</link><dc:creator>likun</dc:creator><author>likun</author><pubDate>Fri, 09 Dec 2011 08:13:00 GMT</pubDate><guid>http://www.cppblog.com/lk624424108/articles/161833.html</guid><wfw:comment>http://www.cppblog.com/lk624424108/comments/161833.html</wfw:comment><comments>http://www.cppblog.com/lk624424108/articles/161833.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lk624424108/comments/commentRss/161833.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lk624424108/services/trackbacks/161833.html</trackback:ping><description><![CDATA[<div>vfork &nbsp;产生的奇怪的现象，求解释<br />代码如下：<span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; ">&nbsp;&nbsp;#include&nbsp;</span><span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; ">&lt;</span><span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; ">stdio.h</span><span class="Apple-style-span" style="font-size: 13px; background-color: #eeeeee; ">&gt;</span></div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all">&nbsp;&nbsp;#include&nbsp;&lt;unistd.h&gt;<br />&nbsp;&nbsp;#include&nbsp;&lt;stdlib.h&gt;&nbsp;<br />&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;main()<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;count=0;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vfork();&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count++;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%d\n",count);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;0;<br />}&nbsp;<br /><br />不知道原因，我的输出是1和12054517 &nbsp;交替出现 n次后停止</div><img src ="http://www.cppblog.com/lk624424108/aggbug/161833.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lk624424108/" target="_blank">likun</a> 2011-12-09 16:13 <a href="http://www.cppblog.com/lk624424108/articles/161833.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>