centos7安装boost记录
centos7騰訊服務(wù)器安裝記
首先打開官網(wǎng)中的下載網(wǎng)頁
downloads頁面
找到你需要的安裝包,我這里選擇的是boost_1_78_0.tar.gz的鏈接,右鍵打開就可以看到有個(gè)復(fù)制鏈接的選項(xiàng)。然后在我的服務(wù)器中輸入獲取壓縮包命令
下載好了以后,你可以在當(dāng)前目錄看到boost_1_78_0.tar.gz的壓縮包,解壓后,進(jìn)行編譯安裝吧。
進(jìn)入安裝目錄,輸入以下命令:
得到以下結(jié)果
Building B2 engine..Could not find a suitable toolset.You can specify the toolset as the argument, i.e.:./build.sh [options] gccToolsets supported by this script are:acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacppFor any toolset you can override the path to the compiler with the '--cxx' option. You can also use additional flags for the compiler with the '--cxxflags' option.A special toolset; cxx, is available which is used as a fallback when a more specific toolset is not found and the cxx command is detected. The 'cxx' toolset will use the '--cxx' and '--cxxflags' options, if present.Options:--help Show this help message.--verbose Show messages about what this script is doing.--debug Build b2 with debug information, and nooptimizations.--guess-toolset Print the toolset we can detect for building.--cxx=CXX The compiler exec to use instead of the detectedcompiler exec.--cxxflags=CXXFLAGS The compiler flags to use in addition to theflags for the detected compiler.Failed to build B2 build engine百度得到的結(jié)果是當(dāng)前的gcc版本不對(duì),然后檢查一下,當(dāng)前版本為4.8.5,的確不對(duì)應(yīng),一般應(yīng)該是gcc7版本,然后切換一下gcc版本,使用centos的scl來進(jìn)行切換
yum install centos-release-scl yum install scl-utils yum install devtoolset-7-toolchain#安裝gcc7版本安裝好了以后查看一下
[root@VM-0-17-centos boost_1_78_0]# scl --list devtoolset-7 [root@VM-0-17-centos boost_1_78_0]# scl enable devtoolset-7 bash [root@VM-0-17-centos boost_1_78_0]# gcc -v gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)的確切換到了gcc7版本,重新跑一下看看
[root@VM-0-17-centos boost_1_78_0]# ./bootstrap.sh Building B2 engine..### ### ### Using 'cxx' toolset. ### ###cpp (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.### ###> cpp -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2 cpp: fatal error: too many input files compilation terminated. > cp b2 bjam cp: cannot stat ‘b2’: No such file or directoryFailed to build B2 build engine嗯,不出所料,還是失敗,沒有編譯成功b2解釋器,最后還是沒能解決問題,準(zhǔn)備在win11的WSL2中試驗(yàn)centos7安裝boost來比對(duì)一下。
win11的centos7子系統(tǒng)安裝
之前在開啟WSL2服務(wù)的時(shí)候就在電腦里面搜索過centos系統(tǒng),結(jié)果商店不支持,都是付費(fèi)的,所以只能通過LxRunOffline來運(yùn)行魔改版的centos了。
首先,LxRunOffline是一個(gè)WSL的第三方工具,是我國(guó)大牛開發(fā)的用來彌補(bǔ)WSL的不足的,主要可以實(shí)現(xiàn)任何Linux發(fā)行版的WSL形式,是個(gè)強(qiáng)大的管理工具,但使用起來卻很簡(jiǎn)單,我們用得上的也就兩個(gè)文件:LxRunOffline.exe和LxRunOfflineShellExt.dll
進(jìn)入github中的下載鏈接(可能很多新學(xué)者不習(xí)慣逛github,但這個(gè)強(qiáng)大的代碼托管平臺(tái)真的很適合你來熟悉),進(jìn)去之后直接下載壓縮包即可,我選擇的是LxRunOffline-v3.5.0-msvc.zip,3.5版本的。
下載好了以后解壓縮,然后得到這兩個(gè)文件:LxRunOfflineShellExt.dll和LxRunOffline.exe,將他們放置到C:\Windows\System32下,然后在這個(gè)文件夾下用管理員身份打開cmd終端輸入以下命令完成功能注冊(cè)。
現(xiàn)在到這里,LxRunOffline就安裝好了,現(xiàn)在我們還需要centos7的魔改版鏡像,也很容易找到,就在LxRunOffline的gitbub項(xiàng)目下的centos分支中
centos7.8鏡像
(點(diǎn)擊界面中的download來下載鏡像,大家應(yīng)該都知道的)
下載好以后需要存放在一個(gè)全英文路徑下(看教程這么說的,但我也沒試過放中文路徑咋樣,類似的情況倒是在其他軟件安裝使用時(shí)試過),然后使用LxRunOffline的install命令,如下:
PS E:\document> LxRunOffline install -n CentOS -f E:\document\centos-7.8.2003-x86_64-docker.tar.xz -d E:\linux\centos7.8 [WARNING] Love this tool? Would you like to make a donation: https://github.com/DDoSolitary/LxRunOffline/blob/master/README.md#donation上面-f參數(shù)就是表明我的centos7.8鏡像位置,-d就是我的centos7的wsl形式安裝路徑,install完畢以后在這個(gè)路徑下就能看到安裝好的目錄列表,畢竟‘linux一切皆文件’(鳥哥說的)。
然后我們可以用LxRunOffline檢查一下當(dāng)前安裝過的linux版本,Ubuntu和Debian都是我通過電腦的軟件商店安裝的,然后Centos是新加的,可以看到在這里有顯示了,另外還需要新增一個(gè)桌面快捷方式,后面的命令就是做這個(gè)作業(yè)的。
也可以通過wsl -d centos的命令在cmd終端進(jìn)行系統(tǒng)切換,效果如下:
PS C:\Users\samu\Desktop> wsl -d centos [root@DESKTOP-SJO8SMG Desktop]# cat /etc/centos-release CentOS Linux release 7.8.2003 (Core)可通過exit方式退出centos,而桌面快捷方式打開是這樣的
要注意的是,這個(gè)時(shí)候的centos系統(tǒng)應(yīng)該是按照最小安裝進(jìn)行的,所以很多命令你在使用的時(shí)候會(huì)出現(xiàn)-bash: command not found的情況。不過幸好它配置了yum安裝工具,你可以很方便的安裝你需要的命令。
–更新一下:除了上面的方式來打開Centos,在上面的都搞定關(guān)機(jī)重啟后使用windows terminal后,應(yīng)該能夠在下面的位置看到centos子系統(tǒng),這樣就能直接打開了。(我的win11是這樣的,其他的不知道,如果有不同的情況請(qǐng)指明,我再更改以免誤導(dǎo)大家)
LxRunOffline的centos7安裝boost記
當(dāng)前所處的centos7有很多命令都需要另外安裝,包括獲取安裝包的wget命令,所以我們先安裝下需要的工具吧。
yum -y install wget yum -y install sudo sudo yum install gcc上面安裝的是gcc4版本,所以上面在centos服務(wù)器上進(jìn)行過的scl操作也要進(jìn)行一次。
yum install centos-release-scl yum install scl-utils yum install devtoolset-7-toolchain#安裝gcc7版本 scl enable devtoolset-7 bash然后就獲取壓縮包,解壓壓縮包,巴拉巴拉。
wget https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz tar xvzf boost_1_78_0.tar.gz切換到boost_1_78_0.tar.gz的根目錄下,運(yùn)行bootstrap.sh腳本生成boost的build程序b2
./bootstrap.sh不過我這個(gè)好像還是有點(diǎn)問題,生成過程中出現(xiàn)Unicode/ICU support for Boost.Regex?.. not found.這樣一個(gè)情況,不過b2好像是生成在本目錄下了,運(yùn)行一下。
./b2 --buildtype=complete install因?yàn)槲蚁胍容^全面地boost庫,所以使用了全部安裝,具體其他參數(shù)大家可以百度一下,應(yīng)該很簡(jiǎn)單就能找到了。說明一下,我這里的安裝都是生成在/usr/local目錄下了,部分實(shí)現(xiàn)文件在lib目錄下,其他大多以.hpp(.h+.cpp,聲明+實(shí)現(xiàn))的形式存放在include目錄下。
測(cè)試如下
尋常編譯,結(jié)果如下:
[root@DESKTOP-SJO8SMG project]# g++ version.cpp -o version [root@DESKTOP-SJO8SMG project]# ./version 107800 1_78 linux GNU C++ version 7.3.1 20180303 (Red Hat 7.3.1-5) GNU libstdc++ version 20180303由于上面的編譯生成是有缺陷的,它跳過了10個(gè)生成項(xiàng)目,至于是哪幾個(gè),目前就看到一個(gè)boost.regex好像有點(diǎn)問題,因?yàn)闆]用到,不確定是不是,只是build記錄這門顯示,項(xiàng)目實(shí)在太多,后面遇到再更新吧。
總結(jié)
以上是生活随笔為你收集整理的centos7安装boost记录的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深刻理解空间(线性空间,度量空间,赋范空
- 下一篇: Android 面试题笔记(一)