Установка g ++ на Windows подсистему для Linux - PullRequest
0 голосов
/ 07 июня 2018

Некоторое время назад я активировал подсистему Windows для Linux на своей машине, но не использовал ее много.Теперь у меня есть идея, для чего я могу его использовать, и именно поэтому я пытаюсь установить gcc / ++ 7 на свой WSL и продолжаю сталкиваться с проблемами.

Моя идея была скачать это и скомпилируйте вручную, следуя этому руководству с:

../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.

Однако при попытке выполнить команду настройки сверху я получил:

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без успеха:

$ 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.Очевидно, что-то более серьезное было сломано.

Ответы [ 3 ]

0 голосов
/ 07 июня 2018

crt1.o обычно предоставляется как часть libdevc зависимости (или чего-то подобного).Я бы посоветовал запустить sudo apt search libc или какой-нибудь аналогичный вариант с lib6c, libdev, libc-dev и т. Д. При установке этих исправлений была обнаружена похожая проблема, с которой я недавно столкнулся.

Если это не удалось, запустите find / -iname ctri.o и добавьтепапка, в которой он отображается в вашей переменной PATH с export PATH="[folder]:$PATH", и посмотрите, поможет ли это.

0 голосов
/ 08 июня 2018

запустите следующее

sudo apt install aptitude
sudo aptitude install gcc-7 g++-7

или

sudo apt install aptitude && sudo aptitude install golang gcc-7 g++-7
0 голосов
/ 07 июня 2018

Зачем компилировать?Вы должны иметь возможность установить пакет:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y

Проверьте с помощью:

gcc-7 --version

См. Как установить gcc-7 или clang 4.0?

...