glib 2.0 arm linux,glib源码安装使用方法
glib库是GTK+和GNOME工程的基础底层核心程序库,是一个综合用途的实用的轻量级的C程序库,它提供C语言的常用的数据结构的定义、相关的处理函数,有趣而实用的宏,可移植的封装和一些运行时机能,如事件循环、线程、动态调用、对象系统等的API。它能够在类UNIX的操作系统平台(如LINUX、HP-UNIX等)、WINDOWS、OS2和BeOS等操作系统台上运行。
本文将介绍在linux下源码安装glib库的过程,这过程很麻烦,一点都不轻松,故记录下。
------
1、安装glib
我下载了个glib-2.48.1.tar.xz,如果是.tar.xz格式用tar -xvf解压,如果是.tar.gz格式用tar -zxvf解压
解压后进入目录后,三部曲:
./configure make make install
看起来是简单,但第一步./configure问题多多,诸多问题请看下面各种解决法子。
2、zlib问题
报错如下:
configure: error: *** Working zlib library and headers not found ***
自glib-2.23开始就需要zlib,zlib是提供数据压缩用的函式库。
(下载地址在网页的中间部分)
我下载了个zlib-1.2.8.tar.gz,解压、进目录,三部曲:
./configure make make install
apt-get install zlib1g-dev
3、libffi问题
报错如下:
No package 'libffi' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBFFI_CFLAGS and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
"FFI" 的全名是Foreign Function Interface,通常指的是允许以一种语言编写的代码调用另一种语言的代码。而libffi库只提供了最底层的、与架构相关的、完整的"FFI",在它之上必须有一层来负责管理两种语言之间参数的格式转换。
我下载了libffi-3.2.1.tar.gz,解压、进目录,三部曲:
./configure make make install
apt-get install libffi-dev
4、pkg-config问题
报错如下:
configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config.
pkg-config能根据软件安装时软件的.pc配置文件路径找到相应的头文件路径和库文件路径。
我下载了pkg-config-0.29.1.tar.gz,解压、进目录,三部曲:
./configure make make install
如果第一步遇到如下错误:
configure: error: Either a previously installed pkg-config or "glib-2.0 >= 2.16" could not be found. Please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure to use the bundled copy.
只需要:
./configure --with-internal-glib
5、pcre问题
报错如下:
configure: error: Package requirements (libpcre >= 8.13) were not met: No package 'libpcre' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables PCRE_CFLAGS and PCRE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括perl兼容的正则表达式库。这些在执行正规表达式模式匹配时用与Perl 5同样的语法和语义是很有用的,也可以来解决C语言中使用正则表达式的问题。
我下载了pcre-8.38.tar.gz,解压、进目录,改动的三部曲:
./configure --enable-utf8 --enable-unicode-properties make make install
如果第一步只是./configure,到时候安装glib会继续报错:
checking for Unicode support in PCRE... no configure: error: *** The system-supplied PCRE does not support Unicode properties or UTF-8.
所以第一步是为了解决Unicode、UTF-8的支持,仅限于pcre7.9以上版本
sudo apt-get install libglib2.0-dev
*安装pcre如果报错如下:
configure: error: You need a C++ compiler for C++ support
那是你所用的linux没支持c++编译,只需要:
apt-get install build-essential
**当安装好pcre后,输入pcretest -C来打印pcre的安装情况,一般输出如下:
PCRE version 8.38 2015-11-23 Compiled with 8-bit support UTF-8 support Unicode properties support No just-in-time compiler support Newline sequence is LF \R matches all Unicode newlines Internal link size = 2 POSIX malloc threshold = 10 Parentheses nest limit = 250 Default match limit = 10000000 Default recursion depth limit = 10000000 Match recursion uses stack
而如果报错为:
pcretest: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory pcretest: error while loading shared libraries: libpcreposix.so.0: cannot open shared object file: No such file or directory
这种情况好像大多数linux都会发生,只需要自己建立一个软链接即可:
ln -s /usr/local/lib/libpcre.so.1 /lib ln -s /usr/local/lib/libpcreposix.so.0 /lib
(如果之后还没用,可以考虑把/lib换/lib64)
6、glib使用方法
*如果都按照上面所列举的种种问题仔细折腾了后还有问题的话,请留言给我。(本人在Kali2、Kali Rolling、Ubuntu等都测试过了)
现在写一个简单的c语言代码,命名为hello.c
#include 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://pcat.cnblogs.com"); printf("The first item is %s\n",g_list_first(list)->data); return 0; }
编译如下:
gcc $(pkg-config --cflags --libs glib-2.0) hello.c -o hello ./hello
如果在一些linux上报错:
undefined reference to `g_list_append' undefined reference to `g_list_first'
那是因为有些gcc存在编译参数的顺序问题,$(pkg-config --cflags --libs glib-2.0)放在源文件的前面,而当编译器在源文件中遇到不能解析的函数时,在源文件之后的选项中寻找相关的信息,那么就出现了编译错误,也就是无法找到相关的函数定义。
所以只需要:
gcc hello.c -o hello $(pkg-config --cflags --libs glib-2.0)
1.查看安装的所有软件
dpkg -l
例如:dpkg -l | grep ftp
2.查看软件安装的路径
dpkg -L | grep ftp
也可以用 whereis ftp
3.查看软件版本
aptitude show
例如:aptitude show ftp
移植glib到arm
error: cannot run test program while cross compiling
./configure --host=arm-linux --cache-file=arm-linux.cache
OK这样就搞定了
glib 2.0 arm linux,glib源码安装使用方法相关推荐
- linux安装glib,glib源码安装使用方法
glib源码下载地址 问题描述:centos 6.5 源码编译qemu ./configure时出现错误 ERROR: glib-2.22 gthread-2.0 is required to c ...
- Linux下源码安装CodeBlocks
Linux下源码安装CodeBlocks qianghaohao(CodingNutter) 一. 安装平台说明: CentOs6.4-i686 gcc-4.4.7 二. 下载最新源码: http: ...
- linux中源码安装node
Linux上安装Node.js 直接使用已经编译好的包 node 官网已经把linux 下载版本更改为已经编译好的版本了,我们可以直接下载解压后使用: wget https://nodejs.org/ ...
- linux python源码安装,linux上源码安装python
以下例子基于python 2.7.9,其他版本同理.# 1.下载python# wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tg ...
- 【 ViSP(1) - Linux Melodic 源码安装 ViSP】
Linux Melodic 源码安装 ViSP Linux Melodic 源码安装 ViSP 1. ViSP 简介 2. 源码安装 2.1 Required packages 需要的安装包 2.2 ...
- 5.3.3.tat.gz php_一步步在LINUX中源码安装PHP运行平台
一步步在LINUX中源码安装PHP运行平台 一步步在LINUX中源码安装PHP运行平台 本人是LINUX新手, 今天我们要学习一下如何在LINUX环境下安装PHP运行环境 目标:在LINUX环境下源码 ...
- linux下源码安装vsftpd-3.0.2
1)在http://vsftpd.beasts.org/网站中查找并下载 vsftpd-3.0.2.tar.gz源码包 2)如果自己的机器上安装有yum可以用yum grouplist | le ...
- Linux ARM机器,源码安装mysql5.7.23,并且运行
背景:华为云 系统版本:EulerOS release 2.0 (SP8) 第一节:源码安装mysql5.7.23 一.下载 yum install ncurses-devel -y yum ins ...
- linux编译安装的好处,Linux学习—源码安装
源码安装--可以按照自己的需求安装,这是源码安装的好处,而二进制安装无法选择 大部分的源码安装步骤大致相同,具体细节可以参考解压缩之后的README和INSTALL README: 介绍了软件包的功能 ...
最新文章
- Ext.js Tree
- CDN 监控系统(二)
- leetcode算法题--环绕字符串中唯一的子字符串★
- Elasticsearch+Kibana 设置连接密码
- 在 PowerPoint 2016 中嵌入网页
- 联想高校AI精英挑战赛总冠军出炉!助力中国迎来智能变革
- scala中的基础语法
- Python包的相对导入时出现错误的解决方法
- 全局角度出发讨论敏捷
- Guava学习笔记(一):Guava新增集合类型-Multimap
- 拓端tecdat|R语言文本主题模型之潜在语义分析(LDA:Latent Dirichlet Allocation)
- 网友热爱的截图软件--Sinpaste
- 英文翻译软件哪个好?不能错过的有这几个。
- 执行stap测试例报错:“insmod: can‘t insert ‘xx.ko‘: invalid module format”
- 如何系统学习Android开发?一线互联网内部整理的Android学习路线图是时候拿出来了
- 瑞士证交所主席认为发行加密瑞士法郎有益经济发展
- CVPR21Look Closer to Segment Better: Boundary Patch Refinement for Instance Segmentation
- java获取国家法定节假日和周末
- Day005 - 循环练习与列表基础
- 【深入理解JVM】:HotSpot垃圾收集器