![C++ 无法在 Ubuntu 18.04 上安装 32 位 gcc-9/g++-9-multilib](https://linux22.com/image/933982/C%2B%2B%20%E6%97%A0%E6%B3%95%E5%9C%A8%20Ubuntu%2018.04%20%E4%B8%8A%E5%AE%89%E8%A3%85%2032%20%E4%BD%8D%20gcc-9%2Fg%2B%2B-9-multilib.png)
我的笔记本电脑上安装了多个版本的 c++ 编译器。我尝试使用带有 32 位编译器的 g++-9.3 构建代码。因此,我尝试使用安装,multilib
并
sudo apt-get install gcc-multilib g++-multilib
尝试安装以下软件包
sudo apt install g++-9-multilib sudo apt install gcc-9-multilib
但结果是
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++-multilib is already the newest version (4:7.4.0-1ubuntu2.3).
gcc-multilib is already the newest version (4:7.4.0-1ubuntu2.3).
0 upgraded, 0 newly installed, 0 to remove and 83 not upgraded.
当前激活的 gcc 是
sudo update-alternatives --config gcc
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-9 60 auto mode
1 /usr/bin/gcc-6 40 manual mode
2 /usr/bin/gcc-7 50 manual mode
3 /usr/bin/gcc-9 60 manual mode
Press <enter> to keep the current choice[*], or type selection number:
> sudo update-alternatives --config g++
There are 3 choices for the alternative g++ (providing /usr/bin/g++).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/g++-9 60 auto mode
1 /usr/bin/g++-6 40 manual mode
2 /usr/bin/g++-7 50 manual mode
3 /usr/bin/g++-9 60 manual mode
> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-11ubuntu0~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-11ubuntu0~18.04.1)
gcc 仍然尝试以 64 位方式构建代码,从而产生编译错误
/usr/include/c++/9/bits/random.h:103:26: error: expected unqualified-id before ‘__int128’
103 | { typedef unsigned __int128 type; };
|
我需要做什么才能apt
安装multlib
g++9.3.0 以便能够编译 32 位代码库?
答案1
我的错,我在 make 文件中进行了以下设置
-I/usr/include/x86_64-linux-gnu/c++/9
删除包含路径后,编译器按预期工作