質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

GCC

GCCはGNU Compiler Collectionの略です。LinuxのC言語コンパイラのデファクトスタンダードであり、数多くの他言語やプラットフォームサポートもします。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Vim

VimとはUnix / Linux 系のOSに標準搭載されているターミナル上で動くテキストエディタです。

apt-get

apt-getコマンドはUNIX系OSのパッケージのインストールなど、パッケージ管理を行うためのコマンドです。

Q&A

解決済

1回答

6632閲覧

Ubuntu20.04でgccができない

grape_ll

総合スコア83

C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

GCC

GCCはGNU Compiler Collectionの略です。LinuxのC言語コンパイラのデファクトスタンダードであり、数多くの他言語やプラットフォームサポートもします。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Vim

VimとはUnix / Linux 系のOSに標準搭載されているターミナル上で動くテキストエディタです。

apt-get

apt-getコマンドはUNIX系OSのパッケージのインストールなど、パッケージ管理を行うためのコマンドです。

0グッド

1クリップ

投稿2020/12/09 13:22

編集2020/12/10 05:55

Ubuntu20.04でcファイルをコンパイル,実行をしようと思って調べたところ
sudo apt-get install gcc
sudo apt-get install vim
をした後にgccを使えば行えると書いてあったのですが,手元でやってみても
gcc -o enc3 enc3.c

Command 'gcc' not found, but can be installed with:

sudo apt install gcc
と出てしまって行えないです.
何が原因なのでしょうか

追記

$ dpkg -l | grep gcc
ii gcc-10-base:amd64 10-20200411-0ubuntu1 amd64 GCC, the GNU Compiler Collection (base package)
ii libgcc-s1:amd64 10-20200411-0ubuntu1 amd64 GCC support library

$ echo $PATH | xargs -d: ls 2>/dev/null | grep gcc
gcc-ar.exe
gcc-nm.exe
gcc-ranlib.exe
gcc.exe
libgcc_s_dw2-1.dll
mingw32-gcc-6.3.0.exe
mingw32-gcc-ar.exe
mingw32-gcc-nm.exe
mingw32-gcc-ranlib.exe
mingw32-gcc.exe
devicengccredprov.dll
ngccredprov.dll

追記2

$ sudo apt install gcc
[sudo] password for alg:
$ dpkg -l | grep gcc
ii gcc-10-base:amd64 10-20200411-0ubuntu1 amd64 GCC, the GNU Compiler Collection (base package)
ii libgcc-s1:amd64 10-20200411-0ubuntu1 amd64 GCC support library

$ echo $PATH | xargs -d: ls 2>/dev/null | grep gcc
gcc-ar.exe
gcc-nm.exe
gcc-ranlib.exe
gcc.exe
libgcc_s_dw2-1.dll
mingw32-gcc-6.3.0.exe
mingw32-gcc-ar.exe
mingw32-gcc-nm.exe
mingw32-gcc-ranlib.exe
mingw32-gcc.exe
devicengccredprov.dll
ngccredprov.dll

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yumetodo

2020/12/09 15:58 編集

dpkg -l | grep gcc と echo $PATH | xargs -d: ls 2>/dev/null | grep gcc の結果を貼ってください
grape_ll

2020/12/10 00:29

質問内容に追記させていただきました.
yumetodo

2020/12/10 02:55

gcc.exe???なんでexe?Linuxのはずなのに???もしかしてWSL2でPATHにWindowsの実行ファイルが紛れ込んでいる・・・? それとgcc入れたって言ってるけど入ってないですよね。もう一度sudo apt install gccしてください
grape_ll

2020/12/10 05:55 編集

知識がないのでexeの話は分かっていないですが, sudo apt install gccを実行しました. もう一度追記させていただきました.
grape_ll

2020/12/10 05:56

今確認してみたのですが,実行しても変化が生じていないようです
yumetodo

2020/12/10 10:07 編集

sudo apt install gccのときに、ちゃんと「続行しますか? [Y/n]」みたいな選択肢にyしてますかね?インストールのログが [sudo] password for alg: だけで終わるなんてありえないんですが
grape_ll

2020/12/10 12:36

そこは見せてもいいのかわからなかったので省いてしまいました ですが自分でyと入力しましたので続行は出来ています.
yumetodo

2020/12/10 13:58

installに成功している状態でもう一度sudo apt install gccすると次のような表示になると思うんです。 $sudo apt install gcc パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 gcc はすでに最新バージョン (4:9.3.0-1ubuntu2) です。 アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 1 個。
grape_ll

2020/12/11 00:54

Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-9 gcc-9 gcc-9-base libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libquadmath0 libtsan0 libubsan1 linux-libc-dev manpages-dev Suggested packages: binutils-doc cpp-doc gcc-9-locales gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-9-multilib gcc-9-doc glibc-doc The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-9 gcc gcc-9 gcc-9-base libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libquadmath0 libtsan0 libubsan1 linux-libc-dev manpages-dev 0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded. Need to get 1138 kB/28.6 MB of archives. After this operation, 123 MB of additional disk space will be used. Do you want to continue? [Y/n] y Ign:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52 Err:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52 404 Not Found [IP: 2001:df0:2ed:feed::feed 80] E: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-48.52_amd64.deb 404 Not Found [IP: 2001:df0:2ed:feed::feed 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? このようになってしまっていますね failedやUnableと出ているのでinstall出来ていないのかもしれません
yumetodo

2020/12/11 06:39

>404 Not Found これ以上なく明確にinstallできてないしこれ以上なく明確に原因がわかるやんけ・・・。 cat /etc/apt/sources.list の結果を追記してください。多分それが壊れてる。
grape_ll

2020/12/20 07:29

返信が遅れて申し訳ありません。いかのようになりました. # See http://ftp.jaist.ac.jp/pub/Linux/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal universe deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal multiverse deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-backports main restricted universe multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu focal partner # deb-src http://archive.canonical.com/ubuntu focal partner deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security main restricted deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security universe deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security multiverse
guest

回答1

0

ベストアンサー

/etc/apt/sources.listはどこかにコピーしてバックアップして、以下の内容で置換してください。

# See http://ftp.jaist.ac.jp/pub/Linux/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal main restricted deb mirror://mirrors.ubuntu.com/mirrors.txt focal main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal main restricted ## Major bug fix updates produced after the final release of the ## distribution. # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates main restricted deb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal universe deb mirror://mirrors.ubuntu.com/mirrors.txt focal universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal universe # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates universe deb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt focal multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal multiverse # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-backports main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt focal-backports main restricted universe multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu focal partner # deb-src http://archive.canonical.com/ubuntu focal partner # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security main restricted deb mirror://mirrors.ubuntu.com/mirrors.txt focal-security main restricted # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security main restricted # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security universe deb mirror://mirrors.ubuntu.com/mirrors.txt focal-security universe # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security universe # deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt focal-security multiverse # deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ focal-security multiverse

その後、

sudo apt update sudo apt upgrade sudo apt install gcc

してください。

投稿2020/12/20 08:57

yumetodo

総合スコア5850

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

grape_ll

2020/12/20 11:13

Failed to save 'sources.list': Command failed: "C:\Users\rokok\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" --file-write "c:\Users\rokok\AppData\Roaming\Code\code-elevated-kinvhm" "z:\etc\apt\sources.list" Using --file-write with invalid arguments. Retry /saveas.../ discard VScodeで置換しようとしたら上記のように表示されてしまったのですがどのように対処すればよいですか?Retryを押してもお同じものが表示されます.
yumetodo

2020/12/20 16:34

いやそりゃ権限が足りてないんでしょうよ。ホームディレクトリかどこかに一回新規作成してsudo mvして移動してsudo chown root:root sources.listしてsudo chmod 644 sources.listしてくださいな。
grape_ll

2020/12/21 01:00

知識が乏しくて申し訳ございません. homeディレクトリでsources.listを新規作成して ~$ sudo mv sources.list apt を行ったのですが,ファイルの更新日時が変更されておらず,一度そこはとばして /etc/apt$ sudo chown root:root sources.list :/etc/apt$ sudo chmod 644 sources.list $ ls -l sources.list -rw-r--r-- 1 root root 2887 Sep 27 17:13 sources.list を行ったのですが,まだvscodeでの編集ができませんでした. 新規作成して移動させるときに,同じ名前の場合は上書きされると思うのですが,その際に権限がなくて上書きできていないのではないかと己うのですが,新規作成の前に前のsources.listは削除するのですか?それとも他の名前で新規作成するのでしょうか. 基本的なところなのかもしれないのですが,よろしくお願いいたします.
yumetodo

2020/12/21 05:38

え、vscodeで編集してから/etc/aptに移動するんですよ・・・?それと私「/etc/apt/sources.listはどこかにコピーしてバックアップして」と書いてるんですが・・・
grape_ll

2020/12/21 06:00

言葉足らずで申し訳ございません.バックアップは他のところにコピーしておいてあります. ですがapt内にsources.listがあると,新規作成したものにいただいたsourceの内容をコピーして,mvをしても更新日時が2020/9/27から変化していないため上書きが出来ていないというのが現状です. apt内のsourcesを切り取りや削除しようとしても権限がないように通知が来て行えていません.
grape_ll

2020/12/21 06:34

現段階で sudo apt update sudo apt upgrade sudo apt install gcc をやってみたらいけました.ありがとうございました.
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問