日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

glib 2.0 arm linux,glib源码安装使用方法

發(fā)布時(shí)間:2023/11/27 linux 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 glib 2.0 arm linux,glib源码安装使用方法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

glib庫是GTK+和GNOME工程的基礎(chǔ)底層核心程序庫,是一個(gè)綜合用途的實(shí)用的輕量級(jí)的C程序庫,它提供C語言的常用的數(shù)據(jù)結(jié)構(gòu)的定義、相關(guān)的處理函數(shù),有趣而實(shí)用的宏,可移植的封裝和一些運(yùn)行時(shí)機(jī)能,如事件循環(huán)、線程、動(dòng)態(tài)調(diào)用、對(duì)象系統(tǒng)等的API。它能夠在類UNIX的操作系統(tǒng)平臺(tái)(如LINUX、HP-UNIX等)、WINDOWS、OS2和BeOS等操作系統(tǒng)臺(tái)上運(yùn)行。

本文將介紹在linux下源碼安裝glib庫的過程,這過程很麻煩,一點(diǎn)都不輕松,故記錄下。

------

1、安裝glib

我下載了個(gè)glib-2.48.1.tar.xz,如果是.tar.xz格式用tar -xvf解壓,如果是.tar.gz格式用tar -zxvf解壓

解壓后進(jìn)入目錄后,三部曲:

./configure make make install

看起來是簡(jiǎn)單,但第一步./configure問題多多,諸多問題請(qǐng)看下面各種解決法子。

2、zlib問題

報(bào)錯(cuò)如下:

configure: error: *** Working zlib library and headers not found ***

自glib-2.23開始就需要zlib,zlib是提供數(shù)據(jù)壓縮用的函式庫。

(下載地址在網(wǎng)頁的中間部分)

我下載了個(gè)zlib-1.2.8.tar.gz,解壓、進(jìn)目錄,三部曲:

./configure make make install

apt-get install zlib1g-dev

3、libffi問題

報(bào)錯(cuò)如下:

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,通常指的是允許以一種語言編寫的代碼調(diào)用另一種語言的代碼。而libffi庫只提供了最底層的、與架構(gòu)相關(guān)的、完整的"FFI",在它之上必須有一層來負(fù)責(zé)管理兩種語言之間參數(shù)的格式轉(zhuǎn)換。

我下載了libffi-3.2.1.tar.gz,解壓、進(jìn)目錄,三部曲:

./configure make make install

apt-get install libffi-dev

4、pkg-config問題

報(bào)錯(cuò)如下:

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能根據(jù)軟件安裝時(shí)軟件的.pc配置文件路徑找到相應(yīng)的頭文件路徑和庫文件路徑。

我下載了pkg-config-0.29.1.tar.gz,解壓、進(jìn)目錄,三部曲:

./configure make make install

如果第一步遇到如下錯(cuò)誤:

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問題

報(bào)錯(cuò)如下:

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)是一個(gè)Perl庫,包括perl兼容的正則表達(dá)式庫。這些在執(zhí)行正規(guī)表達(dá)式模式匹配時(shí)用與Perl 5同樣的語法和語義是很有用的,也可以來解決C語言中使用正則表達(dá)式的問題。

我下載了pcre-8.38.tar.gz,解壓、進(jìn)目錄,改動(dòng)的三部曲:

./configure --enable-utf8 --enable-unicode-properties make make install

如果第一步只是./configure,到時(shí)候安裝glib會(huì)繼續(xù)報(bào)錯(cuò):

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如果報(bào)錯(cuò)如下:

configure: error: You need a C++ compiler for C++ support

那是你所用的linux沒支持c++編譯,只需要:

apt-get install build-essential

**當(dāng)安裝好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

而如果報(bào)錯(cuò)為:

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

這種情況好像大多數(shù)linux都會(huì)發(fā)生,只需要自己建立一個(gè)軟鏈接即可:

ln -s /usr/local/lib/libpcre.so.1 /lib ln -s /usr/local/lib/libpcreposix.so.0 /lib

(如果之后還沒用,可以考慮把/lib換/lib64)

6、glib使用方法

*如果都按照上面所列舉的種種問題仔細(xì)折騰了后還有問題的話,請(qǐng)留言給我。(本人在Kali2、Kali Rolling、Ubuntu等都測(cè)試過了)

現(xiàn)在寫一個(gè)簡(jiǎn)單的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上報(bào)錯(cuò):

undefined reference to `g_list_append' undefined reference to `g_list_first'

那是因?yàn)橛行ゞcc存在編譯參數(shù)的順序問題,$(pkg-config --cflags --libs glib-2.0)放在源文件的前面,而當(dāng)編譯器在源文件中遇到不能解析的函數(shù)時(shí),在源文件之后的選項(xiàng)中尋找相關(guān)的信息,那么就出現(xiàn)了編譯錯(cuò)誤,也就是無法找到相關(guān)的函數(shù)定義。

所以只需要:

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這樣就搞定了

總結(jié)

以上是生活随笔為你收集整理的glib 2.0 arm linux,glib源码安装使用方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

歡迎分享!

轉(zhuǎn)載請(qǐng)說明來源于"生活随笔",并保留原作者的名字。

本文地址:glib 2.0 arm linux,glib源码安装使用方