由于 Linux系统较新,所在glib选择了较新的glib-2.49,安装过程遇到颇多错误,这里只记录正确的成功的安装记录。

# rpm -q ncurses readline lua libffi libffi-devel libiconv xz glib2 cmake popt libnl libevent libevent-devel openssl-devel
ncurses-5.9-14.20130511.el7_4.x86_64
readline-6.2-10.el7.x86_64
lua-5.1.4-15.el7.x86_64
libffi-3.0.13-18.el7.x86_64
libffi-devel-3.0.13-18.el7.x86_64
未安装软件包 libiconv
xz-5.2.2-1.el7.x86_64
glib2-2.46.2-4.el7.x86_64
cmake-2.8.12.2-2.el7.x86_64
popt-1.13-16.el7.x86_64
libnl-1.1.4-3.el7.x86_64
libevent-2.0.21-4.el7.x86_64
libevent-devel-2.0.21-4.el7.x86_64
openssl-devel-1.0.2k-8.0.1.el7.x86_64

libffi依赖包

ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz
tar -zxvf libffi-3.0.13.tar.gz
cd libffi-3.0.13/
./configure --prefix=/usr/local
make
make install

# ll /usr/local/lib | grep libffi
drwxr-xr-x 3 root root 20 11月 20 14:45 libffi-3.0.13

libiconv依赖包
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xvzf libiconv-1.14.tar.gz
cd libiconv-1.14
cd srclib
sed -i -e '/gets is a security/d' ./stdio.in.h
cd ..
注意不要建立独立目录,一定要安装在/usr/local目录下,不然安装glib时会报/usr/bin/ld: cannot find -liconv
./configure --prefix=/usr/local gl_cv_header_working_stdint_h=yes
make
make install

pkg安装
pkg-config is a helper tool used when compiling applications and libraries. It helps you insert the correct compiler options on the command line so an application can use gcc -o test test.c `pkg-config --libs --cflags glib-2.0` for instance,
rather than hard-coding values on where to find glib (or other libraries). It is language-agnostic, so it can be used for defining the location of documentation tools, for instance.

https://www.freedesktop.org/wiki/Software/pkg-config/

tar -zxvf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2/
./configure --enable-iconv=no --with-libiconv=gnu --with-internal-glib
make
make install

ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2
# pkg-config --version
0.29.2

pcre安装
https://sourceforge.net/projects/pcre/files/pcre/
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39/
./configure --enable-utf8 --enable-unicode-properties
pcre-8.39 configuration summary:

Install prefix .................. : /usr/local
C preprocessor .................. : gcc -E
C compiler ...................... : gcc
C++ preprocessor ................ : g++ -E
C++ compiler .................... : g++
Linker .......................... : /usr/bin/ld -m elf_x86_64
C preprocessor flags ............ :
C compiler flags ................ : -g -O2 -fvisibility=hidden
C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
Linker flags .................... :
Extra libraries ................. :

Build 8 bit pcre library ........ : yes
Build 16 bit pcre library ....... : no
Build 32 bit pcre library ....... : no
Build C++ library ............... : yes
Enable JIT compiling support .... : no
Enable UTF-8/16/32 support ...... : yes
Unicode properties .............. : yes
Newline char/sequence ........... : lf
\R matches only ANYCRLF ......... : no
EBCDIC coding ................... : no
EBCDIC code for NL .............. : n/a
Rebuild char tables ............. : no
Use stack recursion ............. : yes
POSIX mem threshold ............. : 10
Internal link size .............. : 2
Nested parentheses limit ........ : 250
Match limit ..................... : 10000000
Match limit recursion ........... : MATCH_LIMIT
Build shared libs ............... : yes
Build static libs ............... : yes
Use JIT in pcregrep ............. : no
Buffer size for pcregrep ........ : 20480
Link pcregrep with libz ......... : no
Link pcregrep with libbz2 ....... : no
Link pcretest with libedit ...... : no
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : no
make
make install
ln -s /usr/local/lib/libpcre.so.1 /lib
ln -s /usr/local/lib/libpcreposix.so.0 /lib

glib安装

http://ftp.acc.umu.se/pub/GNOME/sources/glib/

xz -d glib-2.49.7.tar.xz
chown -R root.root *
tar -xvf glib-2.49.7.tar

mkdir /usr/local/glib-2.49.7
cd glib-2.49.7/
./configure --prefix=/usr/local/glib-2.49.7 --with-libiconv=gnu LIBFFI_CFLAGS="-I/usr/local/include" LIBFFI_LIBS="-L/usr/local/lib -lffi"

# vim ./configure
在7880行之上添加如下内容:
found_iconv=yes

esac
found_iconv=yes
if test "x$found_iconv" = "xno" ; then
as_fn_error $? "*** No iconv() implementation found in C library or libiconv" "$LINENO" 5
fi
fi

make阶段
ln -s /usr/local/lib/libffi-3.0.13/include/ffi.h /usr/local/include
ln -s /usr/local/lib/libffi-3.0.13/include/ffitarget.h /usr/local/include
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2

make
make install

配置PKG-CONFIG
# find /usr/ -name pkgconfig
/usr/lib64/pkgconfig
/usr/share/pkgconfig
/usr/local/lib/pkgconfig
/usr/local/lib64/pkgconfig
/usr/local/mysql/lib/pkgconfig
/usr/local/glib-2.49.7/lib/pkgconfig

# cd /usr/local/glib-2.49.7/lib/pkgconfig
# ls
gio-2.0.pc gio-unix-2.0.pc glib-2.0.pc gmodule-2.0.pc gmodule-export-2.0.pc gmodule-no-export-2.0.pc gobject-2.0.pc gthread-2.0.pc

vim .bash_profile
export PKG_CONFIG_PATH=/usr/local/glib-2.49.7/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/mysql/lib/pkgconfig:$PKG_CONFIG_PATH
. ./.bash_profile

编译测试
vim hello.c
#include <stdio.h>
#include <glib.h>
int main(int argc, char** argv){
GList* list=NULL;
list=g_list_append(list,"Hello world!");
list=g_list_append(list,"made by pcat");
list=g_list_append(list,"http://www.cnblogs.com/perfei/");
printf("The first item is %s\n",g_list_first(list)->data);
return 0;
}

编译如下:
gcc hello.c -o hello $(pkg-config --cflags --libs glib-2.0)

# ls -ltr | grep hello
-rw-r--r-- 1 root root 305 11月 20 16:47 hello.c
-rwxr-xr-x 1 root root 8648 11月 20 17:05 hello

# ./hello
The first item is Hello world!

Linux7.3 glib-2.49安装记录的更多相关文章

  1. 分布式监控系统Zabbix-3.0.3-完整安装记录(7)-使用percona监控MySQL

    前面已经介绍了分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控,但是没有提供可以直接使用的Key,太过简陋,监控效果不佳.要想更加仔细的监控Mysql,业内同学们都会选择 ...

  2. 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用

    关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用   工作环境:window下 在一切的最开始,安装node.js (中文站,更新比较慢http://nodejs.cn/) ...

  3. sourceinsight安装记录

    sourceinsight安装记录 此文章为本人使用sourceinsight一个星期之后的相关设置步骤记录和经验记录,以备以后查验,网上的相关资料都也较为完善,但是对于新手还是有一定困难的,所以在这 ...

  4. openerp安装记录及postgresql数据库问题解决

    ubuntu-14.04下openerp安装记录1.安装PostgreSQL 数据库    a.安装         sudo apt-get install postgresql    安装后ubu ...

  5. Matlab安装记录 - LED Control Activex控件安装

    Matlab安装记录-LED Control Activex控件安装 2013-12-01  22:06:36 最近在研究Matlab GUI技术,准备用于制作上位机程序:在Matlab GUI的技术 ...

  6. Arch Linux 安装记录

    Arch Linux 安装记录 基本上参考wiki上的新手指南,使用arch 2014.6.1 iso安装 设置网络 有线网络 Arch Linux 默认开启DHCP. 静态ip 首先关闭DHCP:s ...

  7. redis5.0.3单实例简单安装记录

    redis5.0.3单实例简单安装记录 日常需要测试使用,索性记录下来,免得临时又麻烦的找资料. yum -y install make gcc-c++ cmake bison-devel ncurs ...

  8. mysql5.7安装记录

    mysql安装记录 版本5.7 windows系统 一.缺少my.ini文件 [mysql]# 设置mysql客户端默认字符集default-character-set=utf8 [mysqld]#设 ...

  9. Liunx/RHEL6.5 Oracle11 安装记录

    1.创建用户组 groupadd oinstall #创建用户组oinstall groupadd dba #创建用户组dba useradd -g oinstall -g dba -m oracle ...

随机推荐

  1. Python 网络爬虫 001 (科普) 网络爬虫简介

    Python 网络爬虫 001 (科普) 网络爬虫简介 1. 网络爬虫是干什么的 我举几个生活中的例子: 例子一: 我平时会将 学到的知识 和 积累的经验 写成博客发送到CSDN博客网站上,那么对于我 ...

  2. linux中怎么结果一页一页输出

    比如sudo apt-cache search php 结果可能有两个屏幕,但是命令执行完毕之后直接就跳到最后面了,我想看第一行怎么办? 可以用管道命令(|)把一个命令的结果作为另一个命令的参数即可. ...

  3. 前端学习笔记2017.6.12 DIV布局网页

    DIV的功能就是把网页划分成逻辑块的. 看下豆瓣东西页面的布局,我们来分析下. 按照先从上到下的原则,把这个页面分成几个块: 首先是最顶端的这个条,这是一个DIV,我们给它起个名字,叫banner 然 ...

  4. CH24C 逃不掉的路

    edcc缩点之后跳倍增lca 丢个edcc缩点模板 Code: #include <cstdio> #include <cstring> using namespace std ...

  5. beforeFilter()

    在控制器每个动作之前执行,可以方便地检查有效的会话,或者检查用户的权限. function beforeFilter() { parent::beforeFilter(); if(empty($thi ...

  6. Entity Framework Tutorial Basics(20):Persistence in Entity Framework

    Persistence in Entity Framework There are two scenarios when persisting an entity using EntityFramew ...

  7. dreamweaver cs5 快捷键

    撤销上一步:ctrl + Z: 回复上一步:ctrl + Y: 代码缩进:左下角(应用原格式)

  8. Java50道经典习题-程序30 插入数字

    题目:有一个已经排好序的数组.现输入一个数,要求将它插入数组中后数组依然是排好序的.分析:首先判断此数是否大于最后一个数,然后再考虑插入中间的数的情况,插入后此元素之后的数,依次后移一个位置. imp ...

  9. 水平居中的那些事之解决jqpagination分页插件无法居中的问题

    固定宽度的元素水平居中只需要 margin-left:auto: margin-right:auto; 换成 margin:0 auto; 也是一样的 今天给我用的jqPagination分页插件实现 ...

  10. EchartJS平均线、最大值、最小值

    1.先来看一个没有平均线.最大值.最小值的简单实例 option = { title: { text: '未来一周气温变化', subtext: '纯属虚构' }, tooltip: { trigge ...