WIN10子系统Ubuntu 18.04 LTS安装g++问题及解决办法

---恢复内容开始---

WIN10有个Linux子系统你们可以去搜搜,我这里装的是【Ubuntu 18.04 LTS】这个版本,要在应用商店搜一下才能出来,如果应用商店搜不到,那就需要你更改系统区域,我是改成了【美国】才搜到的,真是奇葩。

好不容易下载好了之后,又遇到新的问题,那就是gcc装上了,g++装不了。出现的问题参考一下下面这几行:

#####################################

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 build-essential : Depends: libc6-dev but it is not going to be installed or
                            libc-dev
                   Depends: gcc (>= 4:4.4.3) but it is not going to be installed
                   Depends: g++ (>= 4:4.4.3) but it is not going to be installed
E: Broken packages

#####################################

找了好多办法都没解决,各种update、换更新源都没什么用。最后!发现,在apt update之后,其实应该补充一句:

sudo apt upgrade

然后你就可以正常地使用那些网上找到的教程来安装环境了。我使用的是

sudo apt install build-essential

  检查是否安装成功可以使用

gcc -v 或 g++ -v

如果成功的话,就会出现类似像这样的信息:

user@local:~$ g++ -v
Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=‘Ubuntu 7.4.0-1ubuntu1~18.04.1‘ --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --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 --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --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 --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 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

 最后,希望我的经历能帮助你们解决问题。

 

WIN10子系统Ubuntu 18.04 LTS安装g++问题及解决办法

上一篇:ios 客户端定位的3种方法


下一篇:c# 扩展方法