帐前卒专栏

code, software architect, articles and novels.
代码,软件架构,博客和小说

variable 'std:ofstream’ has initializer but incomplete type

或者是 variable 'std:ifstream’ has initializer but incomplete type

其原因是因为没有包含fstream这个头文件。

#include #include #include using namespace std; int
main() { fstream f(“filename”); f << 20; f.close(); }
上面这段代码如果没有那个就会有标题的错误。

Eucalyptus.conf文件:

# Eucalyptus configuration. #### # These are to instruct the init.d script

on what to start. #### # This variable points to where eucalyptus has been
installed. EUCALYPTUS=“/” # This is the username that you would like
eucalyptus to run as EUCA_USER=“eucalyptus” # Uncomment this field if you do
not plan on using the dynamic block # store functionality of Eucalyptus #
DISABLE_EBS=“Y” # Uncomment this field if you do not plan on using the dynamic
DNS # functionality of Eucalyptus DISABLE_DNS=“Y” # This variable controls
whether ws-security is enabled between # eucalyptus components. The default
settings provide secure # connections between the Cloud, Cluster, and Node
Controllers and we # recommend that this feature remains enabled. If you wish
to disable security, # you must change this variable to “N” and manually
configure the # services.xml for both Cluster and Node Controllers (see
documentation # for more details). ENABLE_WS_SECURITY=“Y” # This variable
controls the level of logging output that appears in # various eucalyptus log
files. The options are, in descending order # of verbosity, ‘DEBUG, INFO,
WARN, ERROR, and # FATAL’. The default is DEBUG (everything). LOGLEVEL=“DEBUG”

# These following are Cluster Controller configuration options. ####

This is the port the Cluster Controller will be listening on. CC_PORT=“8774” #
This option configures the Cluster Controller’s scheduling policy. #
Currently, this option can be set to GREEDY (first node that is # found that
can run the VM will be chosen), ROUNDROBIN (nodes are # selected one after
another until one is found that can run the VM), # or POWERSAVE (nodes are put
to sleep when they are not running VMs, # and reawakened when new resources
are required. VMs will be placed # on the first awake machine, followed by
machines that are asleep). SCHEDPOLICY=“ROUNDROBIN” # Powersave options.
POWER_IDLETHRESH is the number of seconds that a # node can remain idle (i.e.
no running VMs) before a powerdown is # attempted. POWER_WAKETHRESH is the
number of seconds that # Eucalyptus should wait after attempting a node wake-
up before it # will consider the node actually down (and not waking up).
POWER_IDLETHRESH=“300” POWER_WAKETHRESH=“300” # The list of Node Controllers
the Cluster Controller will communicate with. # # If you are running Rocks,
you can run “rocks list host” to # find out the list of machines available to
you (in our case we are # interested in the VM Container kind). NODES="
192.168.1.151" # The name of the Node Controller service. Change this if you
want # to plug in your own Node Controller service.
NC_SERVICE=“axis2/services/EucalyptusNC” #### # The following are Node
Controller configuration options. #### # This is the port the Node Controller
will be listening on. NC_PORT=“8775” # The hypervisor that the Node Controller
will interact with in order # to manage virtual machines. Currently, supported
values are ‘kvm’ # and ‘xen’. HYPERVISOR=“xen” # The maximum amount of memory
Eucalyptus is allowed to use on the node: # if you leave this commented out,
Eucalyptus will use all available # memory, otherwise it will use at most this
value for ALL running instances. # MAX_MEM=2048 # The maximum number of
CPU/cores Eucalyptus is allowed to use on the # node (at the moment we don’t
differentiate between cores and CPU). If # you leave this commented out,
Eucalyptus will use all available # CPU/cores it can find. # MAX_CORES=“2” #
The size of the swap partition, in MB, for each instance started on the # node
(default is 512MB). If the maximum disk allowed for the instance # is not big
enough to accommodate the swap together with the root partition, # then no
swap is allocated. If there is extra room left, then an “ephemeral” #
partition will be created, available as /dev/sda3 inside the VM. #
SWAP_SIZE=512 # Setting this to 1 disables the cleanup of instance files
(root, kernel, # ramdisk) for failed and terminated instances. This is not #
recommended for normal use, but it can be useful in debugging VM startup. #
MANUAL_INSTANCES_CLEANUP=0 #### # The following are options for image storage
on the Node Controller #### # This variable points to a directory which is
used by the Node Controller # to store images of running instances as well as
local cached copies of # images. The running images will be deleted after the
instance is # terminated, but the cached copies will persist, subject to LRU
cache # replacement and the NC_CACHE_SIZE size limit, below. So, this #
partition should be at least as big as the cache size (or the maximum # space
needed by all images, whichever is bigger) plus the maximum space # needed by
the maximum number of instances allowed on the node. # This directory should
be local to the Node Controller (as # opposed to a NFS share) for performance
reasons. INSTANCE_PATH=“/usr/local/eucalyptus/” # The maximum amount of disk
space, in Megabytes, that Eucalyptus is # allowed to use in the cache
directory (INSTANCES_PATH/eucalyptus/cache). # A generous size is recommended.
Setting this to zero disables caching. # NC_CACHE_SIZE=99999 #### # The
following are networking options #### # The 2 variable VNET_PRIVINTERFACE and
VNET_PUBINTERFACE specify the # local physical ethernet interfaces that
eucalyptus should use to manage # the VM network. On the front-end,
VNET_PRIVINTERFACE should be set to # the device that is attached to the same
ethernet network as your nodes. # - VNET_PUBINTERFACE should be set to the
device which is connected to # the ‘public’ network. If you have only one
interface, these should # be set to the same value. On the nodes, both should
be set to # either the name of the bridge that has been set up by Xen (xenbr0,

eth0, etc), or the physical ethernet device that is attached to the # xen

bridge (peth0, peth1, etc), depending on your xen configuration.
VNET_PUBINTERFACE=“eth0” VNET_PRIVINTERFACE=“eth0” # (node setting only)
VNET_BRIDGE should be set to the name of the # bridge that xen has configured.
This is typically named ‘xenbr0, # xenbr1, etc’ on older Xen versions, and
‘eth0, eth1, etc’ on newer # Xen versions. The command ‘brctl show’ will give
you more # information on your local bridge setup. #VNET_BRIDGE=“xenbr0” #
This indicates where we have a dhcp server binary. We use it to provide # the
images with IPs: Eucalyptus provides its own configuration per # instance.
VNET_DHCPDAEMON=“/usr/sbin/dhcpd” # Some systems have their DHCP daemon
configured to run as a non-root # user. If this is the case, set the name of
that user here (by # default, Eucalyptus will set up DHCPD configuration files
and # directories as owned by root). #VNET_DHCPUSER=“root” # Following are
example eucalyptus VM networking configurations. # There are four modes to
choose from (MANAGED, MANAGED-NOVLAN, # SYSTEM, or STATIC) and each has its
own sub-options. The first # modes (MANAGED, MANAGED-NOVLAN) configure
eucalyptus to fully manage # the VM networks, and enables the ability to use
security groups and # dynamic public IP assignment (with and without vlan
tagging of # security group networks, respectively). VNET_SUBNET should be set

to an IP subnet that is free for eucalyptus to use (i.e. no other # system

connected to your network directly is configured with # addresses from this
subnet). VNET_NETMASK defines the size of the # subnet. VNET_DNS should be set
to a DNS server that your systems # use (usually safe to use the same DNS that
is configured on the # front-end). VNET_ADDRSPERNET can be used to limit the
number of # instances that can be attached to each named security group #
simultaneously. Finally, VNET_PUBLICIPS should be set to any public # IPs,
that are currently unused, that can be dynamically assigned to # VMs. Of these
options, only VNET_PUBLICIPS can be left blank or # undefined. If you are
running in multi-cluster mode (more than one # CC), you should uncomment
VNET_LOCALIP and set it to the local IP of # the CC that is accessible by all
other CCs in the system. If # VNET_LOCALIP is unset, the CC will try to
determine the list of all # IPs currently assigned to the machine at CC run
time. If your CC # and CLC are on different machines, uncomment VNET_CLOUDIP
and set it # to your cloud-contoller’s IP address (must be an address that can
be # reached by the CC). #VNET_MODE=“MANAGED” #VNET_SUBNET=“192.168.0.0”
#VNET_NETMASK=“255.255.0.0” #VNET_DNS=“your-dns-server-ip”
#VNET_ADDRSPERNET=“32” #VNET_PUBLICIPS=“your-free-public-ip-1 your-free-
public-ip-2 …” #VNET_LOCALIP=“your-public-interface’s-ip” #VNET_CLOUDIP
=“your-cloud-controller’s-ip” # If you would like eucalyptus to not manage the
VM network at all, # you can set VNET_MODE to SYSTEM. In this mode, VM
interfaces are # attached directly to your physical ethernet, at which point
they # will typically invoke a DHCP client to aquire an IP address. Use # this
mode if you wish to manage VM IPs yourself, or allow the VMs to # pick up an
IP from a non-eucalyptus managed DHCP server. VNET_MODE=“SYSTEM” # If
VNET_MODE is set to STATIC, you can manually configure a set of # IP addresses
that will be allocated to VMs at boot time in a first # come, first served
manner. VNET_SUBNET, VNET_NETMASK, and # VNET_BROADCAST define your subnet
(front-end must have an interface # configured on this subnet). VNET_ROUTER
defines the subnet’s # gateway. VNET_DNS is a nameserver address. It is
usually safe to # get these settings by examining your front-end network
settings and # duplicating them here. VNET_MACMAP is a list of mac address/IP

address mappings that you would like to be allocated to VMs at run # time

(see example below for the format of this list). #VNET_MODE=“STATIC”
#VNET_SUBNET=“192.168.1.0” #VNET_NETMASK=“255.255.255.0”
#VNET_BROADCAST=“192.168.1.255” #VNET_ROUTER=“192.168.1.1”
#VNET_DNS=“192.168.1.1” #VNET_MACMAP=“AA:DD:11:CE:FF:ED=192.168.1.2
AA:DD:11:CE:FF:EE=192.168.1.3”

xend-config.sxp文件:

-- sh -- # # Xend configuration file. # # This example configuration is

appropriate for an installation that # utilizes a bridged network
configuration. Access to xend via http # is disabled. # Commented out entries
show the default for that entry, unless otherwise # specified. #(logfile
/var/log/xen/xend.log) #(loglevel DEBUG) (xend-http-server yes) (xend-unix-
server yes) #(xend-tcp-xmlrpc-server no) #(xend-unix-xmlrpc-server yes)
#(xend-relocation-server no) # The relocation server should be kept
desactivated unless using a trusted # network, the domain virtual memory will
be exchanged in raw form without # encryption of the communication. See also
xend-relocation-hosts-allow option (xend-unix-path /var/lib/xend/xend-socket)

Port xend should use for the HTTP interface, if xend-http-server is set.

#(xend-port 8000) # Port xend should use for the relocation interface, if
xend-relocation-server # is set. #(xend-relocation-port 8002) # Address xend
should listen on for HTTP connections, if xend-http-server is # set. #
Specifying ‘localhost’ prevents remote connections. # Specifying the empty
string ‘’ (the default) allows all connections. #(xend-address ‘’) (xend-
address localhost) # Address xend should listen on for relocation-socket
connections, if # xend-relocation-server is set. # Meaning and default as for
xend-address above. #(xend-relocation-address ‘’) # The hosts allowed to talk
to the relocation port. If this is empty (the # default), then all connections
are allowed (assuming that the connection # arrives on a port and interface on
which we are listening; see # xend-relocation-port and xend-relocation-address
above). Otherwise, this # should be a space-separated sequence of regular
expressions. Any host with # a fully-qualified domain name or an IP address
that matches one of these # regular expressions will be accepted. # # For
example: # (xend-relocation-hosts-allow ‘^localhost$ ^.*/.example/.org') # #(xend-relocation-hosts-allow '') (xend-relocation-hosts-allow '^localhost
^localhost//.localdomain$’) # The limit (in kilobytes) on the size of the
console buffer #(console-limit 1024) ## # To bridge network traffic, like
this: # # dom0: fake eth0 -> vif0.0 -+ # | # bridge -> real eth0 -> the
network # | # domU: fake eth0 -> vifN.0 -+ # # use # (network-script network-
bridge) # # Your default ethernet device is used as the outgoing interface, by
default. # To use a different one (e.g. eth1) use # # (network-script
‘network-bridge netdev=eth1’) # # The bridge is named xenbr0, by default. To
rename the bridge, use # # (network-script ‘network-bridge bridge=’) # #
It is possible to use the network-bridge script in more complicated #
scenarios, such as having two outgoing interfaces, with two bridges, and # two
fake interfaces per guest domain. To do things like this, write # yourself a
wrapper script, and call network-bridge from it, as appropriate. # #(network-
script network-bridge) # The script used to control virtual interfaces. This
can be overridden on a # per-vif basis when creating a domain or a configuring
a new vif. The # vif-bridge script is designed for use with the network-bridge
script, or # similar configurations. # # If you have overridden the bridge
name using # (network-script ‘network-bridge bridge=’) then you may wish
to do the # same here. The bridge name can also be set when creating a domain
or # configuring a new vif, but a value specified here would act as a default.

# If you are using only one bridge, the vif-bridge script will discover

that, # so there is no need to specify it explicitly. # (vif-script vif-
bridge) ## Use the following if network traffic is routed, as an alternative
to the # settings for bridged networking given above. #(network-script
network-route) #(vif-script vif-route) ## Use the following if network traffic
is routed with NAT, as an alternative # to the settings for bridged networking
given above. #(network-script network-nat) #(vif-script vif-nat) # Dom0 will
balloon out when needed to free memory for domU. # dom0-min-mem is the lowest
memory level (in MB) dom0 will get down to. # If dom0-min-mem=0, dom0 will
never balloon out. (dom0-min-mem 196) # In SMP system, dom0 will use dom0-cpus

of CPUS # If dom0-cpus = 0, dom0 will take all cpus available (dom0-cpus 0)

Whether to enable core-dumps when domains crash. #(enable-dump no) # The

tool used for initiating virtual TPM migration #(external-migration-tool ‘’) #
The interface for VNC servers to listen on. Defaults # to 127.0.0.1 To restore
old ‘listen everywhere’ behaviour # set this to 0.0.0.0 #(vnc-listen
‘127.0.0.1’) # The default password for VNC console on HVM domain. # Empty
string is no authentication. (vncpasswd ‘’) # The default keymap to use for
the VM’s virtual keyboard # when not specified in VM’s configuration (keymap
‘en-us’) # The VNC server can be told to negotiate a TLS session # to
encryption all traffic, and provide x509 cert to # clients enalbing them to
verify server identity. The # GTK-VNC widget, virt-viewer, virt-manager and
VeNCrypt # all support the VNC extension for TLS used in QEMU. The #
TightVNC/RealVNC/UltraVNC clients do not. # # To enable this create x509
certificates / keys in the # directory /etc/xen/vnc # # ca-cert.pem - The CA
certificate # server-cert.pem - The Server certificate signed by the CA #
server-key.pem - The server private key # # and then uncomment this next line

(vnc-tls 1) # # The certificate dir can be pointed elsewhere… # # (vnc-x509

-cert-dir /etc/xen/vnc) # # The server can be told to request & validate an
x509 # certificate from the client. Only clients with a cert # signed by the
trusted CA will be able to connect. This # is more secure the password auth
alone. Passwd auth can # used at the same time if desired. To enable client
cert # checking uncomment this: # # (vnc-x509-verify 1) # Allow probing of
disk image file format. This is insecure! It lets # a malicious domU read any
file in dom0. Applies only to fully # virtual domUs. Required for using
formats other than raw. #(enable-image-format-probing no) # Number of seconds
xend will wait for device creation #(device-create-timeout 100) # Strict
checking when doing PCI passthrough; enabled by default #(pci-dev-assign-
strict-check yes)

这咋解决呢?

当实例启动后,首先使用euca-describle-instances 查看实例的状态,如果还是处于pending状态,那就需要等待一会。

如果处于running状态。首先去你启动实例的节点上,使用brctl show查看一下网桥是否有问题, 详情见此blog
。然后登录到你的路由上,看看路
由是否开了dhcp服务,或者去提供dhcp服务器的机器,查看dhcp的log。路由中可以在系统状态记录中看到dhcp是否已经分配出去了ip.如果你的dhcp
的log中说已经分配出了ip.那就是用euca-describle-
instances再查看一下。如果还没有分配ip.那就登录到你的head节点中,然后不断的ping你那个刚刚分配的ip即可。然后再使用euca-
describle-instances就可以看到ip了。

如果你的路由之下的ip可能和你路由之外的ip冲突,你也可以拔下路由与外网的接口试试。

不过这里有点诡异的地方就是我的路由dhcp设置为8~252,也就是应该分配8到252之间的地址。结果实例得到的地址全部都是小于8的地址。不知道是路由dhcp
的错还是我哪里设置错误。

桥接模式:

关闭 Xend:
xend stop

修改 Xend 配置文件 /etc/xen/xend-config.sxp ,取消下面两行的注释:
(network-script network-bridge)
(vif-script vif-bridge)

启动 Xend:
xend start

DomU 配置文件中不需要指定 IP:
vif = [‘’]

也可以指定 IP:
vif = [‘ip=192.168.1.252’]

创建 DomU。在 DomU 里配置 eth0 的 IP。如果在配置文件里指定了 IP,则必须保持一致:
ifconfig eth0 192.168.1.252

如果需要连接外网,需要配置网关,例如:
route add default gw 192.168.1.254

如果这时可以ping通外网ip但是不能进行域名解析,就更改/etc/resolv.conf文件。注意这里是resolv.conf而不是resolve.con
f.

如果希望使用dhcp服务,可以在DomU的config文件中配置dhcp = “dhcp”。

假如使用以上配置后,进入DomU,ping不同外网,也ping不同自己的物理机,但是能ping通自己。那说明网桥处连接有问题。

使用brctl show来查看网桥。这里需要注意的是:vif0.0代表的是Dom0的网络接口,vifX.0代表的是DomU的网络接口。X和DomU的id有关
系。。peth0是物理网卡接口。网桥如果可以通信,vif0.0,vifX.0,peth0必须在一个网桥之下。这里的网桥类似于xenbr0,virbr0的形式
。注意这里是两个不同的网桥。所以必须都在同一个网桥之下才行。如果不在的话,在DomU的config中设置vif =
[‘bridge=xenbr0’]就可以了。

如果brctl show显示依旧不在同一网桥。那么就只写 vif = [‘bridge=xenbr0’],也不要配置mac和ip,进入虚拟机之后再配置。

另外如果有出现输入xend命令dom-0自动断网的情况,可能需要禁掉selinux和iptable.

传说转自科苑星空…

调程序的小女孩

实验室里冷极了,没有窗户,不知道是白天还是黑夜。这是一周的最后一天——周

末。在这又冷又黑的晚上,一个蓬头散发的小女孩在工位上坐着。她从家里出来的时候

还穿着一件外套,但是有什么用呢?那是一件很大的外套──那么大,不知是哪一年买

的。她工作的时候的,就把它脱掉了,实验室的师弟嘲笑说,可以拿它当抹布。

小女孩只好一个人做实验,一双小脚冻得红一块青一块的。她的破显示器屏幕上有

一大段程序,手里草稿纸上还有一大段。这一整天,程序还是没调过,谁也没帮过她。

可怜的小女孩!她又冷又饿,哆哆嗦嗦地调程序。显示器的光落在她的干枯的长头

发上,那头发卷曲着披在肩上,看上去很久没梳,不过她没注意这些。每个桌上都堆满

了论文,实验室飘着一股油墨的香味,因为这是论文deadline的时间——她可忘不了这

个。

她在一行代码上停了下来,蜷着趴在桌子上。她觉得更冷了。她不敢跟老板说,因

为她程序没调过,没拿到一个数据,老板一定会骂她的。再说,换做别的题目跟这个一

样难。她们头上只有paper,虽然网上可以下到一些现成的代码,还是仍然没法用。

她的头脑几乎绝望了。啊,哪怕一次小小的成功,对她也是有好处的!她敢把上万

行的代码修改一遍。编译运行一下,来找找问题么?她终于按下回车键开始运行。哧!

程序开始输出信息了!一行一行的log开始出来了!她把小手拢在显示器上。多么温暖多

么明亮的字符啊,简直像一支小小的蜡烛。这是一道奇异的火光!小女孩觉得自己好像

坐在一个19寸液晶大显示器前面,显示器还是全新锃亮的,颜色鲜艳,字迹清晰,上边

显示着程序输出的正确结果,多么舒服啊!哎,这是怎么回事呢?她刚把头伸出去,想

看的仔细一些,程序crash了,大显示器不见了。她坐在那儿,眼前的破显示器上一行刺

眼的segment fault。

她又编译了一遍运行。程序又开始输出信息了,给出log了。显示器的光落在桌子上

,那儿忽然变得像打印出来的paper那样洁白工整,她可以一直看到paper上的字迹。IE

EE的logo,会议名称和日期,Abstract和Instroduction。更妙的是这篇paper的一作,

赫然署着自己的名字!看上去那么诱惑,一直向这个穷苦的小女孩走来。这时候,程序

又crash了,她面前只剩一张又硬又旧的桌子。

她又运行了一遍。这一回,她感觉自己坐在布置整齐的会议室里。条幅上写着“博

士毕业答辩”,比她去年师姐毕业时用的条幅还要大,还要美。红色的条幅上贴着那几

个白色的黑体字,投影仪屏幕上许多幅美丽的彩色画片,跟顶级会议里的presentation

一个样,在向她眨眼睛。小女孩向画片伸出手去。这时候,程序又crash了。只见ppt上

的图片越升越高,最后成了在天空中闪烁的星星。有一颗星星落下来了,在天空中划出

了一道细长的红光。

“有一个什么人快要死了。”小女孩说。唯一疼她的师姐毕业前的时候告诉过她:

一颗星星落下来,就有一个灵魂要到图灵那儿去了。

她又编译了一遍。这一回,她把所有的数组size都设大了。师姐出现在亮光里,是

那么温和,那么慈爱。

“师姐!”小女孩叫起来,“啊!请把我带走吧!我知道,程序一crash,您就会不

见的,像那漂亮的显示器,发表的paper,布置好的答辩会议室一个样,就会不见的!”

她赶紧按了回车键,要把师姐留住。一大堆输出信息发出强烈的光,把实验室照得

跟白天一样明亮。师姐从来没有像现在这样高大,这样美丽。师姐把小女孩抱起来,搂

在怀里。她们俩在光明和快乐中飞走了,越飞越高,飞到那没有代码,没有论文,也没

有毕业的地方去了。

第二天清晨,这个小女孩坐在工位上,两腮通红,嘴上带着微笑。她死了,在周末

的实验室累死了。新一周的太阳升起来了,照在她小小的尸体上。小女孩坐在那儿,手

还按着在知用过多少年的键盘上。

“她想自己把程序调一下……”人们说。谁也不知道她曾经看到过多么美丽的东西

,她曾经多么幸福,跟着她师姐一起走向新世界的幸福中去。

我觉得我的blog应该进行国际化…根据google的Analytics,已经有外国人开始访问了…虽然还不知道访问了啥米…但是国际化势在必行呼哈哈

自动化生成的例子还可以参照:http://blog.csdn.net/sayigood/archive/2009/12/07/4954772.aspx

转载自:http://blog.chinaunix.net/u3/90876/showart_2072884.html

第一步:
----------
在/root/project/main目录下创建一个文件main.c,其内容如下:
------------------------------------------------
#include <stdio.h>
int main(int argc, char** argv)
{
printf(“Hello, Auto Makefile!/n”);
return 0;
}
------------------------------------------------

此时状态如下:
[root@localhost main]# ** pwd **
/root/project/main
[root@localhost main]# ** ls **
** main.c **
[root@localhost main]#

第二步:
----------
运行 ** autoscan ** , 自动创建两个文件: autoscan.log  configure.scan

此时状态如下:
[root@localhost main]# ** autoscan **
[root@localhost main]# ** ls **
** autoscan.log  configure.scan ** main.c
[root@localhost main]#

第三步:
----------
修改configure.scan的文件名为configure.in

查看 ** configure.in ** 的内容:
------------------------------------------------
#                                               -- Autoconf --

Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([config.h])

Checks for programs.

AC_PROG_CC

Checks for libraries.

Checks for header files.

Checks for typedefs, structures, and compiler characteristics.

Checks for library functions.

AC_OUTPUT
------------------------------------------------

解读以上的文件:

------------------------------------------------
#                                               -- Autoconf --

Process this file with autoconf to produce a configure script.

AC_PREREQ:

确保使用的是足够新的Autoconf版本。如果用于创建configure的Autoconf的版

本比version 要早,就在标准错误输出打印一条错误消息并不会创建configure。

AC_PREREQ(2.61)

初始化,定义软件的基本信息,包括设置包的全称,版本号以及报告BUG时需要用的邮箱地址

AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)

用来侦测所指定的源码文件是否存在,来确定源码目录的有效性

AC_CONFIG_SRCDIR([main.c])

用于生成config.h文件,以便autoheader使用

AC_CONFIG_HEADER([config.h])

Checks for programs.

AC_PROG_CC

Checks for libraries.

Checks for header files.

Checks for typedefs, structures, and compiler characteristics.

Checks for library functions.

创建输出文件。在`configure.in’的末尾调用本宏一次。

AC_OUTPUT
------------------------------------------------

修改动作:
1.修改AC_INIT里面的参数: AC_INIT(main,1.0, [email protected])
2.添加宏AM_INIT_AUTOMAKE,
它是automake所必备的宏,也同前面一样,PACKAGE是所要产生软件套件的名称,VERSION是版本编号。
3.在AC_OUTPUT后添加输出文件Makefile
修改后的结果:
------------------------------------------------
#                                               -- Autoconf --

Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
** AC_INIT(main, 1.0, [email protected]) **
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([config.h])
** AM_INIT_AUTOMAKE(main,1.0) **

Checks for programs.

AC_PROG_CC

Checks for libraries.

Checks for header files.

Checks for typedefs, structures, and compiler characteristics.

Checks for library functions.

** AC_OUTPUT([Makefile]) **
------------------------------------------------

第四步:
运行 ** aclocal ** , 生成一个“ ** aclocal.m4 ** ”文件和一个缓冲文件夹 ** autom4te.cache **
,该文件主要处理本地的宏定义。

此时的状态是:
[root@localhost main]# ** aclocal **
[root@localhost main]# ** ls **
** aclocal.m4  autom4te.cache ** autoscan.log  configure.in  configure.in~  main.c
[root@localhost main]#
第五步:
运行 ** autoconf ** , 目的是生成 configure

此时的状态是:
[root@localhost main]# ** autoconf **
[root@localhost main]# ** ls **
aclocal.m4      autoscan.log  configure.in   main.c
autom4te.cache ** configure ** configure.in~
[root@localhost main]#

第六步:
运行 ** autoheader ** ,它负责生成config.h.in文件。该工具通常会从“acconfig.h”文件中复制用户附加的符号定义,因此此处
没有附加符号定义,所以不需要创建“acconfig.h”文件。

此时的状态是:
[root@localhost main]# ** autoheader **
[root@localhost main]# ** ls **
aclocal.m4      autoscan.log  configure     configure.in~
autom4te.cache ** config.h.in ** configure.in  main.c
[root@localhost main]#

第七步:
下面即将运行 ** automake ** , 但在此之前应该做一下准备工作!

首先
创建一个 ** Makefile.am ** .这一步是创建Makefile很重要的一步,automake要用的脚本配置文件是Makefile.am,用户需
要自己创建相应的文件。之后,automake工具转换成Makefile.in

这个Makefile.am的内容如下:
------------------------------------------------
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
------------------------------------------------

下面对该脚本文件的对应项进行解释。
其中的AUTOMAKE_OPTIONS为设置automake的选项。由于GNU(在第1章中已经有所介绍)对自己发布的软件有严格的规范,比如必须附
带许可证声明文件COPYING等,否则automake执行时会报错。automake提供了三种软件等级:foreign、gnu和gnits,让用
户选择采用,默认等级为gnu。在本例使用foreign等级,它只检测必须的文件。
bin_PROGRAMS定义要产生的执行文件名。如果要产生多个执行文件,每个文件名用空格隔开。
main_SOURCES定义“main”这个执行程序所需要的原始文件。如果”main”这个程序是由多个原始文件所产生的,则必须把它所用到的所有原
始文件都列出来,并用空格隔开。例如:若目标体“main”需要“main.c”、“sunq.c”、“main.h”三个依赖文件,则定义
main_SOURCES=main.c sunq.c
main.h。要注意的是,如果要定义多个执行文件,则对每个执行程序都要定义相应的file_SOURCES。

其次
使用automake对其生成“configure.in”文件,在这里使用选项“—adding-
missing”可以让automake自动添加有一些必需的脚本文件。
运行后的状态是:
------------------------------------------------
[root@localhost main]# ** automake --add-missing **
configure.in:8: installing ./missing' configure.in:8: installing ./install-sh’
Makefile.am: installing `./depcomp’
[root@localhost main]# ** ls **
aclocal.m4      config.h.in   configure.in~  main.c        Makefile.in
autom4te.cache  configure ** depcomp ** ** Makefile.am ** ** missing **
autoscan.log    configure.in ** install-sh ** Makefile.am~
[root@localhost main]#
------------------------------------------------

第八步
运行 ** configure ** ,在这一步中,通过运行自动配置设置文件configure,把Makefile.in变成了最终的Makefile。
运行的结果如下:
------------------------------------------------
[root@localhost main]# ** ./configure **
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for style of include used by make… GNU
checking dependency style of gcc… gcc3
configure: creating ./config.status
** config.status: creating Makefile
** config.status: creating config.h
config.status: executing depfiles commands
[root@localhost main]# ls
aclocal.m4      config.h.in    configure.in   main.c        Makefile.in
autom4te.cache  config.log     configure.in~  Makefile ** missing **
autoscan.log    config.status ** depcomp ** Makefile.am ** stamp-h1 **
** config.h ** configure ** install-sh ** Makefile.am~
[root@localhost main]#
------------------------------------------------

第九步
运行 ** make ** ,对配置文件Makefile进行测试一下

此时的状态如下:
------------------------------------------------
[root@localhost main]# ** make **
cd . && /bin/sh /root/project/main/missing --run aclocal-1.10
cd . && /bin/sh /root/project/main/missing --run automake-1.10 --foreign
cd . && /bin/sh /root/project/main/missing --run autoconf
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure   --no-create --no-recursion
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for style of include used by make… GNU
checking dependency style of gcc… gcc3
configure: creating ./config.status
/bin/sh ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
cd . && /bin/sh /root/project/main/missing --run autoheader
rm -f stamp-h1
touch config.h.in
make  all-am
make[1]: Entering directory /root/project/main' gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c mv -f .deps/main.Tpo .deps/main.Po gcc  -g -O2   -o main main.o cd . && /bin/sh ./config.status config.h config.status: creating config.h config.status: config.h is unchanged make[1]: Leaving directory /root/project/main’
[root@localhost main]# ** ls **
aclocal.m4      autoscan.log  config.h.in  config.status  configure.in
depcomp ** main    main.o ** Makefile.am   Makefile.in  stamp-h1
autom4te.cache  config.h      config.log   configure      configure.in~
install-sh  main.c  Makefile  Makefile.am~  missing
[root@localhost main]#
------------------------------------------------

第十步
运行生成的文件 main:
------------------------------------------------
[root@localhost main]# ** ./main **
Hello, Auto Makefile!
[root@localhost main]#

如果自然语言处理技术不错的话,其实没有必要人来标注Tag.因为Tag其实就是关键词也就是keyword.多少年前就有从文中抽取关键字的技术。不过可能还不成熟
。所以才需要人为添加Tag.所谓的Tag Cloud,其实是根据Tag的不同权重而对Tag进行展现的方式,其实是一个很不错的人机接口。

Tag的作用其实很多,比如做索引,或者做abstract,或者做文章之间的关联度分析。不管怎样,平均来说比原来文章字数上要少很多。所以也就好做处理。可以认为
是一种降低复杂度的方法。

自己一直在做开源方面的工作,包括源代码的搜集整理。同时也看过不少源代码。不过当前开源界的代码大部分处于无注释或少注释状态,有的代码只有license是注释.
…如果是少数几个人开发,大家都相互认识,只不过是借用了开源这个壳来完成自己的事情的话,无注释也没有什么大不了的。开源的代码的很多,不过成功的太少。也有
很多代码写得很烂,也少人问津。

开源项目的类型大概有四种,可能总结的不是很全面。1,已经有相关功能的实现,但是没有开源。2我或者周围的人知道某种需求并没有人实现。3为完成推广活动,而开源。
4,just for fun.

开源项目是否要依照经典的软件过程来走?答案是不确定。很少有开源软件有自己的蓝图,连linux都没有!也就是说开源软件大部分时间处于无设计阶段。因为没有明确的
需求,也就没有明确的设计。大部分需求是几个核心组织者拍拍脑袋得到的idea以及以前版本中得到的用户反馈。

那么今后的开源应该做成什么样子呢?我个人认为第一至少API化。读源码然后做逆向工程,然后再更改少量代码,除了用来骗钱,增强个人能力外,对真正意义上的快速开发
作用并不大。如果有编程API可用,为何不直接调用,还要读大量的相关源码呢?公司会傻到先让程序员看linux核心代码再编c程吗?第二要有软件蓝图。此开源软件的
未来究竟是什么样子的,应该明确一下。有啥功能不再升级应该说一下。否则使用了某个功能模块,结果下个版本说因为含有系统漏洞而不再支持。那借助此开源软件的开发者就
疯了。第三相关功能的融合。A开源软件有下载模块,B开源软有下载模块,C…,为啥不整合到一起,形成API呢?当然会有人说因为使用不同,下载方式及流程可能
有不同。但是我想一个gcc有约上百个参数供人调用,一个下载模块提供几十个参数应该也就够用了。分散力量做某事,往往做得不好。第四,当前软件的框架结构、文档和注
释应该整齐。开发者往往不屑于文档,这是通病。“代码就是文档”这只对开发此代码的人适用。另外某些公司把自己的代码开源了,结果代码里只有license是注释。我
觉得这些代码还不如用混淆器混淆一下然后再宣布自己支持开源来得痛快。我个人认为开源应该是为别人提供方便,而不仅仅为了做个代码的网上备份。不过当前为了宣传和推广
开源,这些同学的做法还是欢迎的。但是这样的做法肯定不是推崇的。第五,开源项目应该有专门的培训人员。现在大部分项目都宣称来IRC上问问题吧,大家都会解答。这其
实是一种责任分散的做法。心理学上讲当责任分散到每个人身上,那每个人也就没有责任了。例如大家都围观落水者或者急需救助的人,而不提供援手。所以我建议开源项目应有
专人培训新人。

回顾自己的文章,好像是对开源软件的建议,并没有和题目所写的开源软件的未来相联系。我个人能力有限,的确很难预测未来。未来还是靠我们共同创造吧。😃

欢迎开源人士评阅。但言辞不要激进,smile again:)

因为我这里的连接分为国内国外。最近因为国外流量少,而是用国内流量上网。却发现很多过去用国内连接曾经能打开网页,现在都打不开了。包括gmail,g.cn,xi
aonei.com,xunlei.com,baidu.com,163.com等,不过还好,csdn还是能打开的。过去是用多内连接,登录QQ和飞信也是可以的,
现在也不行了。

所以我得出两个可能的结论:1,可能是那群网管希望多挣我的钱。故意让网络中国内连接打不开知名网站。2,知名网站纷纷迁移到国外的服务器。

另外我想我们还是要少依赖于那些搜索引擎。万一他们都game
over了。我难道就没有办法上网了?sigh~搭建自己的搜索引擎…或许是个不错的想法。😃

0%