centos 编译安装glib

下载最新的glib.2.28.2

./configure --prefix=/usr

make clean && make && make install

 

(1)遇到问题

make的时候 缺少 magic.h头文件;这个头文件在centos的/usr/include/linux/里确实没有,我把http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/include/linux/magic.h这个,直接拷贝到/usr/include/linux/下,顺利通过;

 

(2)make的时候出现这个错误: http://blog.csdn.net/saint1126/archive/2011/01/17/6147169.aspx

make[4]: Entering directory `/root/Desktop/glib-2.26.0/gio/tests'  

/usr/bin/msgfmt -o test.mo ./de.po; /  

  •         /bin/mkdir -p de/LC_MESSAGES; /  
  •         cp -f test.mo de/LC_MESSAGES  
  • ./de.po:15: 关键字“msgctxt”未知  
  • ./de.po:15:8: parse error  
  • /usr/bin/msgfmt: 发现 2 处致命错误
  • 原因:需要升级gettext package的库,操作如下:

    1.  wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz  
    2. tar xvzf gettext-0.18.1.1.tar.gz   
    3. cd gettext-0.18.1.1  
    4. ./configure  
    5. make  
    6. make install  
    7. ldconfig  

     这里在网上随便找了一个test:

    /* until.c 用来测试实用功能 */
    #include <glib.h>
    int main(int argc, char *argv[])
    {
     GRand *rand;
     GTimer *timer;
     
     gint n;
     gint i, j;
     gint x = 0;
     rand = g_rand_new(); //创建随机数对象
     for(n=0; n<20; n++)
     { //产生随机数并显示出来
      g_print("%d/t",g_rand_int_range(rand,1,100));
     }
     g_print("/n");
     g_rand_free(rand); //释放随机数对象
     //创建计时器
     timer = g_timer_new();
     g_timer_start(timer);//开始计时
     for(i=0; i<10000; i++)
      for(j=0; j<3000; j++)
       x++;//累计
     g_timer_stop(timer);//计时结束
     //输出计时结果
     g_print("%ld/tall:%.2f seconds was used!/n",x,g_timer_elapsed(timer,NULL));
    }

    使用这个编译: gcc -g `pkg-config --cflags --libs glib-2.0` t_glib.c -o t_glib

      

     

     

     

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值