您的位置:首页 > 运维架构 > Linux

linux下使用gflags编译glog

2015-04-22 18:57 274 查看
想在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文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  glog