linux下使用gflags编译glog

想在glog中使用gflags,但是gflags并没有安装在系统的默认目录下,因为我没有root权限,glog文档上有这么一段:
Several flags influence glog's output behavior. If the Google gflags library is installed on your machine, the configure script (see the INSTALL file in the package for detail of this script) will automatically detect and use it, allowing you to pass flags on the command line. For example, if you want to turn the flag --logtostderr on, you can start your application with the following command line:
这里只说了安装在默认路径下,对于定制路径,我只好自己来尝试了。

最终的configure命令:
./configure --prefix=/home/xxx/sbin/glog-0.3.4/ --with-gflags=/home/xxx/sbin/gflags --disable-shared -with-pic
./configure --prefix=/home/xxx/sbin/glog-0.3.4/ --with-gflags=/home/xxx/sbin/gflags --disable-shared
备注:gflags和glog都安装在指定的目录下而不是系统默认目录,通过源代码安装

过程:
1. 
使用 ./configure --prefix=/home/xxx/sbin/glog-0.3.4/
生成的Makefile:ac_cv_have_libgflags = 0
查看configure.ac中:
130 # Check if there is google-gflags library installed.
131 SAVE_CFLAGS="$CFLAGS"
132 SAVE_LIBS="$LIBS"
133 AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR],
134   GFLAGS_CFLAGS="-I${with_gflags}/include"
135   GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
136   CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
137   LIBS="$LIBS $GFLAGS_LIBS"

我就直接使用了--with-gflags=来指示gflags的路径

2. 
使用: ./configure --prefix=/home/xxx/sbin/glog-0.3.4/ --with-gflags=/home/xxx/sbin/gflags
make
报错:
/home/xxx/sbin/gflags/lib/libgflags.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:1041: recipe for target 'libglog.la' failed
make: *** [libglog.la] Error 1
网上搜到了文章:http://blog.chinaunix.net/uid-20470603-id-3671388.html,找到了添加的参数,但是具体原因我还不是太懂

3. 
使用: ./configure --prefix=/home/xxx/sbin/glog-0.3.4/ --with-gflags=/home/xxx/sbin/gflags --disable-shared -with-pic
ok,只是没有so文件,只有*.a文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值