re2c在BC-Linux服務器上源碼編譯和安裝

BC-Linux上安裝re2c

\color{red}{提示:一旦涉及編譯源碼安裝髓绽,你需要安裝的基本的依賴項有:git、autoconf圈膏、automake他去、libtool浮还、make、cmake拜鹤。}

我在安裝 ninja 軟件包時遇到一個問題框冀,如下所示:

warning: A compatible version of re2c (>= 0.15.3) was not found; changes to src/.in.cc will not affect your build*.

這里提示 re2c 沒有找到,查閱了一下敏簿,re2c 是一個將正則表達式轉化成基于 C 語言標識的預處理器明也。于是想著從 github 上安裝一下這個軟件包。過程中碰到一些問題惯裕,所以想記錄一下分享出來温数。

從GitHub上下載 re2c 項目源碼

  • 在 GitHub 上搜索 re2c


    在GitHub上搜索re2c項目
  • 找到最新版releases版本源碼


    點擊Releases進入
  • 下載項目源碼


    下載最新的項目源碼壓縮包

編譯和安裝

  • 將下載好的壓縮包放到 Linux 服務器上,我這里放到了 /home/share/ 目錄下蜻势,然后解壓

解壓命令:tar -xvzf re2c-3.0.tar.gz

[root@localhost share]# ls -d re2c*
re2c-3.0  re2c-3.0.tar.gz
[root@localhost share]# 

可以看到已經將文件解壓到了 re2c-3.0 文件夾中了撑刺。

  • 進入 re2c-3.0 目錄查看
[root@localhost share]# cd re2c-3.0/
[root@localhost re2c-3.0]# ls
add-release.txt  build      CMakeLists.txt     doc       lib          Makefile.am      release.sh       test
autogen.sh       BUILD.md   CMakePresets.json  examples  libre2c_old  Makefile.lib.am  run_tests.py.in
benchmarks       CHANGELOG  configure.ac       fuzz      LICENSE      NO_WARRANTY      sf-cheatsheet
bootstrap        cmake      CONTRIBUTING.md    include   m4           README.md        src
[root@localhost re2c-3.0]# 

查看后發(fā)現沒有 configure 配置文件,此時我們運行 autogen.sh 腳本來生成 configure文件握玛。

  • 運行 autogen.sh
[root@localhost re2c-3.0]# ./autogen.sh 
fatal: Not a git repository (or any of the parent directories): .git
./autogen.sh: line 5: autoreconf: command not found
[root@localhost re2c-3.0]# 

這里有一個 fatal 的錯誤提示說:當前的目錄不是一個 git 倉庫够傍。這個錯誤其實不影響編譯。為了不顯示這個錯誤挠铲,保證安裝的順利冕屯,我們可以在本地創(chuàng)建一個 git 倉庫,然后將解壓的 re2c-3.0 解壓文件夾拷貝到git倉庫目錄下拂苹,再執(zhí)行 autogen.sh 腳本文件安聘。

[root@localhost share]# git init github_re2c
Initialized empty Git repository in /home/share/github_re2c/.git/
[root@localhost share]# cd github_re2c/
[root@localhost github_re2c]# cp ../re2c-3.0.tar.gz ./
[root@localhost github_re2c]# ls
re2c-3.0.tar.gz
[root@localhost github_re2c]# tar -xvzf re2c-3.0.tar.gz
>>>>>>>>>>>>>> 中間的解壓過程省略 <<<<<<<<<<<<<<
[root@localhost github_re2c]# 
[root@localhost github_re2c]# ls
re2c-3.0  re2c-3.0.tar.gz
[root@localhost github_re2c]# cd re2c-3.0/
[root@localhost re2c-3.0]# ls
add-release.txt  build      CMakeLists.txt     doc       lib          Makefile.lib.am  run_tests.py.in
autogen.sh       BUILD.md   CMakePresets.json  examples  libre2c_old  NO_WARRANTY      sf-cheatsheet
benchmarks       CHANGELOG  configure.ac       fuzz      LICENSE      README.md        src
bootstrap        cmake      CONTRIBUTING.md    include   Makefile.am  release.sh       test
[root@localhost re2c-3.0]#
[root@localhost re2c-3.0]# ./autogen.sh 
./autogen.sh: line 5: autoreconf: command not found
[root@localhost re2c-3.0]# 

這樣就不會報上面的錯誤了。此時提示 autoreconf: command not found,這是由于沒有安裝 autoconf 軟件包導致的搞挣。

  • 安裝 autoconf
[root@localhost re2c-3.0]# yum install autoconf
Configuration file /etc/yum/pluginconf.d/license-manager.conf not found
Unable to find configuration file for plugin license-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed

>>>>>>>>>>>>>> 中間的安裝過程省略 <<<<<<<<<<<<<<
Installed:
  autoconf.noarch 0:2.69-11.el7                                                                                

Dependency Installed:
  m4.x86_64 0:1.4.16-10.el7                        perl-Data-Dumper.x86_64 0:2.145-3.el7                       

Complete!
[root@localhost re2c-3.0]# 
  • 再次運行 autogen.sh
[root@localhost re2c-3.0]# ./autogen.sh 
Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
[root@localhost re2c-3.0]#

此時又提示 Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.带迟,這是由于沒有安裝 automake 軟件包導致的

  • 安裝 automake
[root@localhost re2c-3.0]# yum install automake
Configuration file /etc/yum/pluginconf.d/license-manager.conf not found
Unable to find configuration file for plugin license-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package automake.noarch 0:1.13.4-3.el7 will be installed

>>>>>>>>>>>>>> 中間的安裝過程省略 <<<<<<<<<<<<<<
Installed:
  automake.noarch 0:1.13.4-3.el7                                                                               

Dependency Installed:
  perl-Test-Harness.noarch 0:3.28-3.el7                                                                        

Complete!
[root@localhost re2c-3.0]# 
  • 三次運行 autogen.sh
[root@localhost re2c-3.0]# ./autogen.sh 
configure.ac:3: installing 'build-aux/install-sh'
configure.ac:3: installing 'build-aux/missing'
Makefile.am:515: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:515:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:515:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:515:   If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:515:   its definition is in aclocal's search path.
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
autoreconf: automake failed with exit status: 1
[root@localhost re2c-3.0]# 

又出現一個錯誤:Makefile.am:515: error: Libtool library used but 'LIBTOOL' is undefined,這是由于沒有安裝 libtool 導致的囱桨。

  • 安裝 libtool
[root@localhost re2c-3.0]# yum install libtool
Configuration file /etc/yum/pluginconf.d/license-manager.conf not found
Unable to find configuration file for plugin license-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package libtool.x86_64 0:2.4.2-22.el7_3 will be installed

>>>>>>>>>>>>>> 中間的安裝過程省略 <<<<<<<<<<<<<<
Installed:
  libtool.x86_64 0:2.4.2-22.el7_3                                                                              

Complete!
[root@localhost re2c-3.0]# 
  • 四次運行 autogen.sh
[root@localhost re2c-3.0]# ./autogen.sh 
Removing aclocal.m4
Removing config.h.in
Removing configure
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
configure.ac:191: installing 'build-aux/config.guess'
configure.ac:191: installing 'build-aux/config.sub'
[root@localhost re2c-3.0]# 

到這里終于運行成功了仓犬,查看目錄下生成了 configure 文件。

[root@localhost re2c-3.0]# ls
aclocal.m4       bootstrap  cmake              configure.ac     include      Makefile.am      release.sh
add-release.txt  build      CMakeLists.txt     CONTRIBUTING.md  lib          Makefile.in      run_tests.py.in
autogen.sh       build-aux  CMakePresets.json  doc              libre2c_old  Makefile.lib.am  sf-cheatsheet
autom4te.cache   BUILD.md   config.h.in        examples         LICENSE      NO_WARRANTY      src
benchmarks       CHANGELOG  configure          fuzz             m4           README.md        test
[root@localhost re2c-3.0]# 
  • 運行 configure 配置文件
[root@localhost re2c-3.0]# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
>>>>>>>>>>>>>> 中間的安裝過程省略 <<<<<<<<<<<<<<
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@localhost re2c-3.0]# 

執(zhí)行完之后舍肠,查看目錄搀继,已經生成了 Makefile 文件

[root@localhost re2c-3.0]# ls
aclocal.m4       build-aux          config.h.in      examples     m4               release.sh
add-release.txt  BUILD.md           config.log       fuzz         Makefile         run_tests.py
autogen.sh       CHANGELOG          config.status    include      Makefile.am      run_tests.py.in
autom4te.cache   cmake              configure        lib          Makefile.in      sf-cheatsheet
benchmarks       CMakeLists.txt     configure.ac     libre2c_old  Makefile.lib.am  src
bootstrap        CMakePresets.json  CONTRIBUTING.md  libtool      NO_WARRANTY      stamp-h1
build            config.h           doc              LICENSE      README.md        test
[root@localhost re2c-3.0]# 
  • 執(zhí)行 makemake install 命令進行編譯和安裝
    此處編譯和安裝日志較多,所以不在累贅寫出翠语。

  • 查看安裝版本

[root@localhost re2c-3.0]# re2c -version
re2c 3.0
[root@localhost re2c-3.0]# 

安裝好之后查看版本叽躯,顯示安裝的是 re2c 3.0 版本,說明安裝已經成功肌括。

從 EPEL 中安裝 re2c

安裝 re2c 還有另外一種方式点骑,那就是從 EPEL 中直接安裝,最為方便快捷谍夭,一般都能滿足要求黑滴,但不是最新的版本。

安裝步驟分兩步:

  1. 安裝軟件擴展包 EPEL
  2. 安裝 re2c

1. 安裝 EPEL

EPEL 的安裝請參考文章《Linux上安裝EPEL擴展包》紧索,這里不再講述袁辈。

2. 安裝 re2c

命令:yum install re2c

[root@localhost ~]# yum install re2c
Extra Packages for Enterprise Linux 7 - x86_64                      14 kB/s |  17 MB     20:50    
Last metadata expiration check: 0:10:35 ago on Sun 05 Mar 2023 06:49:56 PM EST.
Dependencies resolved.
===================================================================================================
 Package             Architecture          Version                       Repository           Size
===================================================================================================
Installing:
 re2c                x86_64                0.14.3-2.el7                  epel                230 k

>>>>>>>>>>>>>> 中間的安裝過程省略 <<<<<<<<<<<<<<
Installed:
  re2c-0.14.3-2.el7.x86_64                                                                         

Complete!
[root@localhost ~]# 

查看安裝版本

[root@localhost code]# re2c -version
re2c 0.14.3
[root@localhost code]# 

4. 總結

編譯和安裝的依賴項

  1. 依賴項:git、autoconf珠漂、automake晚缩、libtool。git 本地倉庫的新建媳危,所有的操作在本地倉庫目錄下進行荞彼。
  2. 安裝 epel,然后從 epel 中安裝 re2c

\color{red}{提示:一旦涉及編譯源碼安裝待笑,你需要安裝的基本的依賴項有:git鸣皂、autoconf、automake滋觉、libtool签夭、make齐邦、cmake椎侠。}

好了,re2c 的安裝分享完畢措拇,希望幫到你我纪,謝謝閱覽。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市浅悉,隨后出現的幾起案子趟据,更是在濱河造成了極大的恐慌,老刑警劉巖术健,帶你破解...
    沈念sama閱讀 219,490評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件汹碱,死亡現場離奇詭異,居然都是意外死亡荞估,警方通過查閱死者的電腦和手機咳促,發(fā)現死者居然都...
    沈念sama閱讀 93,581評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來勘伺,“玉大人跪腹,你說我怎么就攤上這事》勺恚” “怎么了冲茸?”我有些...
    開封第一講書人閱讀 165,830評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長缅帘。 經常有香客問我轴术,道長,這世上最難降的妖魔是什么股毫? 我笑而不...
    開封第一講書人閱讀 58,957評論 1 295
  • 正文 為了忘掉前任膳音,我火速辦了婚禮,結果婚禮上铃诬,老公的妹妹穿的比我還像新娘祭陷。我一直安慰自己,他們只是感情好趣席,可當我...
    茶點故事閱讀 67,974評論 6 393
  • 文/花漫 我一把揭開白布兵志。 她就那樣靜靜地躺著,像睡著了一般宣肚。 火紅的嫁衣襯著肌膚如雪想罕。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,754評論 1 307
  • 那天霉涨,我揣著相機與錄音按价,去河邊找鬼。 笑死笙瑟,一個胖子當著我的面吹牛楼镐,可吹牛的內容都是我干的。 我是一名探鬼主播往枷,決...
    沈念sama閱讀 40,464評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼框产,長吁一口氣:“原來是場噩夢啊……” “哼凄杯!你這毒婦竟也來了?” 一聲冷哼從身側響起秉宿,我...
    開封第一講書人閱讀 39,357評論 0 276
  • 序言:老撾萬榮一對情侶失蹤戒突,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后描睦,有當地人在樹林里發(fā)現了一具尸體膊存,經...
    沈念sama閱讀 45,847評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,995評論 3 338
  • 正文 我和宋清朗相戀三年忱叭,在試婚紗的時候發(fā)現自己被綠了枯芬。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片详囤。...
    茶點故事閱讀 40,137評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出地消,到底是詐尸還是另有隱情速梗,我是刑警寧澤良蒸,帶...
    沈念sama閱讀 35,819評論 5 346
  • 正文 年R本政府宣布舟扎,位于F島的核電站,受9級特大地震影響千康,放射性物質發(fā)生泄漏享幽。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,482評論 3 331
  • 文/蒙蒙 一拾弃、第九天 我趴在偏房一處隱蔽的房頂上張望值桩。 院中可真熱鬧,春花似錦豪椿、人聲如沸奔坟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,023評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽咳秉。三九已至,卻和暖如春鸯隅,著一層夾襖步出監(jiān)牢的瞬間澜建,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,149評論 1 272
  • 我被黑心中介騙來泰國打工蝌以, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留炕舵,地道東北人。 一個月前我還...
    沈念sama閱讀 48,409評論 3 373
  • 正文 我出身青樓跟畅,卻偏偏與公主長得像咽筋,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子碍彭,可洞房花燭夜當晚...
    茶點故事閱讀 45,086評論 2 355

推薦閱讀更多精彩內容