用dw做的網(wǎng)站怎么放到網(wǎng)上google谷歌搜索主頁
文章目錄
- Ubuntu下安裝GCC
- 查看官方安裝指導
- 錯誤
- 缺少`gmp`庫
- 缺少`32`位開發(fā)庫`libc`
- g++: error: gengtype-lex.c: No such file or directory
- reference
歡迎訪問個人網(wǎng)絡日志🌹🌹知行空間🌹🌹
Ubuntu下安裝GCC
為了支持新的c++
標準,需要安裝新的GCC
,安裝步驟如下.
查看官方安裝指導
GCC
版本查看,截止20240324
,gcc
最新的版本為13.2
,支持到了c++23
標準。
版本發(fā)布信息可以參考:GCC Releases查看。
安裝指導參考的網(wǎng)頁為:【GCC Installation Instructions】
- 檢查安裝依賴,
- 下載源碼,可使用
git
命令克隆
git clone git://gcc.gnu.org/git/gcc.git
# 查看所有分支
git branch -a
# 查看所有標簽
git tag -l
有時候,國內訪問gcc
放置代碼的git
倉庫速度會很慢,這個時候可以從開源中國的碼云平臺上下載,
https://gitee.com/mirrors/gcc.git
這個是國內鏡像,可以加速下載速度。
- 下載源碼后,切入源碼目錄,執(zhí)行如下命令下載依賴
./contrib/download_prerequisites
- 配置,可在源碼倉庫下新建
build
目錄,然后切換到build
目錄下執(zhí)行如下命令進行配置。
../configure --enable-languages=c,c++ --prefix=/usr/local/gcc-13.2.0 --host=x86_64-pc-linux-gnu --prefix=/home/xx/data/sw/gcc13 --disable-multilib
更多的配置參數(shù)可以參考頁面https://gcc.gnu.org/install/configure.html
- 安裝
make -j4
sudo make install
- 驗證安裝
/usr/local/gcc-13.2.0/bin/gcc --version
- 設置環(huán)境變量
export PATH=$PATH:/usr/local/gcc-13.2.0/bin
- 卸載
sudo rm -rf /usr/local/gcc-13.2.0
錯誤
缺少gmp
庫
xx@xx-rob:~/data/code/gcc$ ./configure --enable-languages=c,c++ --prefix=/usr/local/gcc-13.2.checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
解決方法,先執(zhí)行命令:
xx@xx-rob:~/data/code/gcc$ ./contrib/download_prerequisites2024-03-21 22:31:18 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.2.1.tar.bz2 [2493916/2493916] -> "gmp-6.2.1.tar.bz2" [1]
2024-03-21 22:33:48 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-4.1.0.tar.bz2 [1747243/1747243] -> "mpfr-4.1.0.tar.bz2" [1]2024-03-21 22:34:29 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.2.1.tar.gz [838731/838731] -> "mpc-1.2.1.tar.gz" [1]
2024-03-21 22:35:49 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2 [2261594/2261594] -> "isl-0.24.tar.bz2" [1]
gmp-6.2.1.tar.bz2: OK
mpfr-4.1.0.tar.bz2: OK
mpc-1.2.1.tar.gz: OK
isl-0.24.tar.bz2: OK
All prerequisites downloaded successfully.
缺少32
位開發(fā)庫libc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.
解決辦法:
- 安裝
32
位libc
庫文件 ./configure
時使用參數(shù)--disable-multilib
禁用編譯32
位平臺上可以使用的庫
g++: error: gengtype-lex.c: No such file or directory
編譯過程中報錯:
> and I found the Makefile in my objdir directory. I try `make -j4` and found
> g++: error: gengtype-lex.c: No such file or directory
> g++: fatal error: no input files
> Could you help me with this?
解決辦法:
缺少flex
庫文件,手動安裝:
sudo apt-get install flex
reference
1.https://www.spinics.net/lists/gcchelp/msg50998.html
歡迎訪問個人網(wǎng)絡日志🌹🌹知行空間🌹🌹