zoukankan      html  css  js  c++  java
  • glib-2.40编译安装

    1 安装glib库所需要的依赖库:
    libffi-3.0.0.tar.gz
    glib-2.40.0.tar.xz
    安装依赖库libffi:
    tar xf libffi-3.0.0.tar.gz
    cd libffi-3.0.0
    ./configure
    make
    make install
     
    配置环境变量:
    vim /etc/profile
    添加下面的内容:
    export LIBFFI_CFLAGS=-I/usr/local/lib/libffi-3.0.0/include
    export LIBFFI_LIBS=/usr/local/lib/libffi.la
    export C_INCLUDE_PATH=/usr/local/lib/libffi-3.0.0/include/
     
    使配置文件立即生效
    source /etc/profile
     
    安装glib库:
    configure 配置选项
    --enable-debug=no 选项:默认是mini模式,在release的时候应该使用该选项
    --disable-included-printf 选项:这个选项要谨慎使用,可能会造成某些 printf 家族的函数不能使用
     
    tar xf glib-2.40.0.tar.xz
    cd glib-2.40.0
    ./configure --enable-debug=no
    make
    make install
     
     
    配置环境变量:
    vim /etc/profile
    添加下面的内容:
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
     
    使配置文件立即生效
    source /etc/profile
     
     
    2 使用 glib 库,测试字符串使用为例
    vim test.c
     
    #include <stdio.h>
    #include <glib.h>
    int main(int argc, char *argv[])
    {
    GString *teststr = NULL;
    teststr = g_string_new("1234");
    printf ("str is:%s
    ", teststr->str);
    printf ("len is:%d
    ", teststr->len);
    g_string_free (teststr, TRUE);
    teststr = NULL;
    g_return_val_if_fail (teststr, NULL);
    return 0;
    }
    gcc -I /usr/local/include/glib-2.0/ -I /usr/local/lib/glib-2.0/include/ -L/usr/local/lib -lglib-2.0
    
    ./a.out
     
    这里运行可以发现断言会被打印,glib提供了关闭断言的开关
    在使用glib库的程序中屏蔽断言需要在编译时加入开关
    gcc -I /usr/local/include/glib-2.0/ -I /usr/local/lib/glib-2.0/include/ -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -lglib-2.0
    运行程序后断言不打印
     
    注意:使用glib库的时候最好是不要关闭断言,因为断言是预防程序 coredump 的最后屏障
  • 相关阅读:
    Thread.sleep(0)的意义& 多线程详解
    .NET AOP的实现
    UML详解
    asp.net事件委托易理解实例
    2个或多个datable类似于sql inner join 合并查询
    web.cofing(新手必看)
    JS操作URL
    .net对象转Datable
    NPOI读写Excel
    RSA加密
  • 原文地址:https://www.cnblogs.com/etangyushan/p/6710168.html
Copyright © 2011-2022 走看看