在Windows子系统上安装g for linux
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在Windows子系统上安装g for linux,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4224字,纯文字阅读大概需要7分钟。
内容图文
![在Windows子系统上安装g for linux](/upload/InfoBanner/zyjiaocheng/953/00fc801f93a94412b35d55c30860abaf.jpg)
前段时间我在我的机器上激活了Windows子系统Linux,但没有使用它.现在我知道我可以使用它,这就是为什么我试图在我的WSL上安装gcc / 7并继续遇到问题.
我的想法是download它并在this guide之后用手编译:
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=${HOME}/software/gcc-7.3.0/installDir --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib
这导致以下错误:
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking LIBRARY_PATH variable... ok
checking GCC_EXEC_PREFIX variable... ok
checking whether to place generated files in the source directory... no
checking whether a default linker was specified... no
checking whether a default assembler was specified... no
checking for x86_64-linux-gnu-gcc... no
checking for gcc... no
checking for x86_64-linux-gnu-cc... no
checking for cc... no
checking for x86_64-linux-gnu-cl.exe... no
checking for cl.exe... no
configure: error: in `$HOME/software/gcc-7.3.0/build':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
显然,根本没有安装(?)gcc.至少gcc和cc产生了“未找到命令”.所以我的下一步是通过以下方式安装gcc:
sudo apt install gcc
这有效:
$gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
Copyright (C) 2013 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.
但是当从上面尝试configure命令时,我得到了:
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking LIBRARY_PATH variable... ok
checking GCC_EXEC_PREFIX variable... ok
checking whether to place generated files in the source directory... no
checking whether a default linker was specified... no
checking whether a default assembler was specified... no
checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc
checking for C compiler default output file name...
configure: error: in `/home/seriously-ubuntu/software/gcc-7.3.0/build':
configure: error: C compiler cannot create executables
see `config.log' for more details.
所以我试着手工编译一个简单的c程序:
int main() {
return 42;
}
这暗示某些事情似乎被严重打破了
$gcc foo.c
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
有什么想法,我甚至可以开始修复这个?如果这有帮助,我甚至不介意重置整个WSL:/
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
更新:
在所有这些之前,我尝试安装gcc7 / g / via apt但没有成功:
$sudo add-apt-repository ppa:jonathonf/gcc-7.1
$sudo apt-get update
$sudo apt-get install gcc-7 g++-7
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:
g++-7 : Depends: libstdc++-7-dev (= 7.1.0-10ubuntu1~16.04.york0) but it is not going to be installed
Depends: libisl15 (>= 0.15) but it is not installable
gcc-7 : Depends: cpp-7 (= 7.1.0-10ubuntu1~16.04.york0) but it is not going to be installed
Depends: binutils (>= 2.26.1) but 2.24-5ubuntu14.2 is to be installed
Depends: libisl15 (>= 0.15) but it is not installable
Recommends: libc6-dev (>= 2.13-0ubuntu6) but it is not going to be installed
E: Unable to correct problems, you have held broken packages
更新2
可悲的是,没有一个建议的方法有帮助,我最终搞砸了WSL.显然,更严重的事情被打破了.
解决方法:
为什么要编译?您应该能够安装该软件包:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y
验证使用:
gcc-7 --version
见How to install gcc-7 or clang 4.0?
内容总结
以上是互联网集市为您收集整理的在Windows子系统上安装g for linux全部内容,希望文章能够帮你解决在Windows子系统上安装g for linux所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。