不久前,我在我的机器上激活了Windows Subsystem for 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
更新:
在此之前,我尝试通过apt安装gcc7 / g++/,但没有成功:
$ 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。显然,一些更严重的东西被打破了。
发布于 2018-06-07 05:05:21
为什么要编译?您应该能够安装该程序包:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y
使用以下命令进行验证:
gcc-7 --version
发布于 2018-06-08 13:39:00
运行以下命令
sudo apt install aptitude
sudo aptitude install gcc-7 g++-7
或
sudo apt install aptitude && sudo aptitude install golang gcc-7 g++-7
发布于 2018-06-07 07:05:48
crt1.o
通常是作为libdevc
依赖项(或类似的东西)的一部分提供的。我建议在lib6c
,libdev
,libc-dev
等平台上运行sudo apt search libc
或类似的变种。安装它们修复了我最近遇到的类似问题。
如果失败,请运行find / -iname ctri.o
并使用export PATH="[folder]:$PATH"
将它所在的文件夹添加到您的路径中,看看这是否有帮助。
https://stackoverflow.com/questions/50729550
复制相似问题