源码编译依赖关系一例小结

今天星痕(网名)搭建nagios整合平台,编译ndoutils-1-5的时候出现问题,遂一起研究
mysql用的是源码5.5.11安装的,在编译的时候使用不同参数,configure能正常通过,make却报错,也有configure报错,nake却正常的
更详细的ndoutils安装问题,请看此文 http://hi.baidu.com/dongjunjia/blog/item/3c0043ed27a52a372697919f.html
这里,我主要是记录下解决此问题的方法
#./configure --prefix=/usr/local/nagios --enable-mysql  LDFLAGS=-L/usr/local/mysql --with-mysql-inc=/usr/local/mysql/include  --with-ndo2db-user=nagios --with-ndo2db-group=nagios --with-mysql=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
前面省略掉……
checking for initgroups... yes
checking for strtof... yes
checking for type of socket size... size_t
checking for linker flags for loadable modules... -shared
checking for mysql_init in -lmysqlclient... yes
MySQL library and include file(s) were found!
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating docs/docbook/en-en/Makefile
config.status: creating subst
config.status: creating include/config.h

*** Configuration summary for ndoutils 1.5 02-03-2012 ***:
 General Options:
 -------------------------
 NDO2DB user:    nagios
 NDO2DB group:   nagios

Review the options above for accuracy.  If they look okay,
type 'make' to compile the NDO utilities
.
 configure是成功的
[root@localhost ndoutils-1-5]# make
cd ./src && make
make[1]: Entering directory `/root/nagios/nd2db_test/ndoutils-1-5/src'
gcc -fPIC -g -O2 -I/usr/local/mysql/include -DHAVE_CONFIG_H  -c -o io.o io.c
在包含自 io.c:11 的文件中:
../include/config.h:261:25: 错误:mysql/mysql.h:没有那个文件或目录
../include/config.h:262:26: 错误:mysql/errmsg.h:没有那个文件或目录
make[1]: *** [io.o] 错误 1
make[1]: Leaving directory `/root/nagios/nd2db_test/ndoutils-1-5/src'
make: *** [all] 错误 2
[root@localhost ndoutils-1-5]#
这里make出错,那么查看提示,无法找到mysql.h  errmsg.h
先在系统里面找这2个文件
[root@localhost ndoutils-1-5]# find /usr/local/mysql/ -name mysql.h
/usr/local/mysql/include/mysql.h
[root@localhost ndoutils-1-5]# find /usr/local/mysql/ -name errmsg.h
/usr/local/mysql/include/errmsg.h
第二看报错信息  ../include/config.h  那么由此可以看到  上面2个出错文件是由config .h定义的
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
找到这2个文件的位置
从这里可以看出  mysql/mysql.h mysql/errmsg.h  在系统里面是无法找到的,所以修改如下
#include </usr/local/mysql/include/mysql.h>
#include </usr/local/mysql/include/errmsg.h>
再次make 则顺利通过
当然,处理上面的问题,还可以通过建立链接的方式
对上面解决问题的思路做一个总结:
编译源码包,通常会遇到N多依赖关系,常常提示无法找到某文件,缺少某依赖包,有时候装上相关软件,还是无法继续
往往给我们带来很多麻烦。对于此类问题,首先是找到错误提示信息,针对错误提示,分析系统是否有这个文件,再次是分析源码文件的库文件相关应用位置,上例中,正是由于库文件引用不正确导致的,所以很容易就把吃问题解决了。
   解决问题的方法不重要,思路却是最重要的,思路清晰了,方法自然来了 ,希望给大家带来一点收获
                                                                                 itnihao 2012-02-29于成都

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值