gcc找不到Linux/in,已安装GCC,但找不到命令

新用户在Linux上遇到gcc命令找不到的问题,尽管已经安装了GCC。在/usr/local/bin目录下看到多个GCC版本的软链接,但gcc命令仍然显示未找到。执行brew doctor显示警告,包括Homebrew版本过时、未链接的kegs、路径问题和未提交的Homebrew修改。尝试修改PATH和创建gcc符号链接未成功,寻求解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我是Linux新手,而且我很难尝试完成这项工作。 我卸载并安装了gcc几次。现在,当我运行gcc --version时,它仍然表示zsh: command not found。已安装GCC,但找不到命令

当我去/usr/local/bin和运行ls -l我找到GCC的多个版本

lrwxr-xr-x 1 ps032791 admin 33 Jul 2 2014 c++-4.6 -> ../Cellar/gcc46/4.6.4/bin/c++-4.6

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 11:58 c++-4.7 -> ../Cellar/gcc47/4.7.3/bin/c++-4.7

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 15:27 c++-4.8 -> ../Cellar/gcc/4.8.3_1/bin/c++-4.8

lrwxr-xr-x 1 ps032791 admin 32 Apr 6 15:19 cloog -> ../Cellar/cloog/0.18.1/bin/cloog

lrwxr-xr-x 1 ps032791 admin 33 Jul 2 2014 cpp-4.6 -> ../Cellar/gcc46/4.6.4/bin/cpp-4.6

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 11:58 cpp-4.7 -> ../Cellar/gcc47/4.7.3/bin/cpp-4.7

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 15:27 cpp-4.8 -> ../Cellar/gcc/4.8.3_1/bin/cpp-4.8

lrwxr-xr-x 1 ps032791 admin 28 May 29 2014 erb -> ../Cellar/ruby/2.1.2/bin/erb

lrwxr-xr-x 1 ps032791 admin 33 Jul 2 2014 g++-4.6 -> ../Cellar/gcc46/4.6.4/bin/g++-4.6

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 11:58 g++-4.7 -> ../Cellar/gcc47/4.7.3/bin/g++-4.7

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 15:27 g++-4.8 -> ../Cellar/gcc/4.8.3_1/bin/g++-4.8

-rw-r--r-- 1 ps032791 admin 0 Apr 6 13:23 gcc-4.2

lrwxr-xr-x 1 ps032791 admin 33 Jul 2 2014 gcc-4.6 -> ../Cellar/gcc46/4.6.4/bin/gcc-4.6

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 11:58 gcc-4.7 -> ../Cellar/gcc47/4.7.3/bin/gcc-4.7

lrwxr-xr-x 1 ps032791 admin 33 Apr 6 15:27 gcc-4.8 -> ../Cellar/gcc/4.8.3_1/bin/gcc-4.8

lrwxr-xr-x 1 ps032791 admin 36 Apr 6 11:58 gcc-ar-4.7 -> ../Cellar/gcc47/4.7.3/bin/gcc-ar-4.7

lrwxr-xr-x 1 ps032791 admin 36 Apr 6 15:27 gcc-ar-4.8 -> ../Cellar/gcc/4.8.3_1/bin/gcc-ar-4.8

lrwxr-xr-x 1 ps032791 admin 36 Apr 6 11:58 gcc-nm-4.7 -> ../Cellar/gcc47/4.7.3/bin/gcc-nm-4.7

lrwxr-xr-x 1 ps032791 admin 36 Apr 6 15:27 gcc-nm-4.8 -> ../Cellar/gcc/4.8.3_1/bin/gcc-nm-4.8

lrwxr-xr-x 1 ps032791 admin 40 Apr 6 11:58 gcc-ranlib-4.7 -> ../Cellar/gcc47/4.7.3/bin/gcc-ranlib-4.7

lrwxr-xr-x 1 ps032791 admin 40 Apr 6 15:27 gcc-ranlib-4.8 -> ../Cellar/gcc/4.8.3_1/bin/gcc-ranlib-4.8

我跑'酿造医生,我得到下面的输出,

Warning: You have MacPorts or Fink installed:

/opt/local/bin/port

This can cause trouble. You don't have to uninstall them, but you may want to

temporarily move them out of the way, e.g.

sudo mv /opt/local ~/macports

Warning: Your Homebrew is outdated.

You haven't updated for at least 24 hours, this is a long time in brewland!

To update Homebrew, run `brew update`.

Warning: You have unlinked kegs in your Cellar

Leaving kegs unlinked can lead to build-trouble and cause brews that depend on

those kegs to fail to run properly once built. Run `brew link` on these:

gcc48

Warning: You have uncommitted modifications to Homebrew

If this a surprise to you, then you should stash these modifications.

Stashing returns Homebrew to a pristine state but can be undone

should you later need to do so for some reason.

cd /usr/local/Library && git stash && git clean -d -f

Warning: /usr/bin occurs before /usr/local/bin

This means that system-provided programs will be used instead of those

provided by Homebrew. The following tools exist at both paths:

erb

gem

git

git-cvsserver

git-receive-pack

git-shell

git-upload-archive

git-upload-pack

irb

rake

rdoc

ri

ruby

testrb

Consider setting your PATH so that /usr/local/bin

occurs before /usr/bin. Here is a one-liner:

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

我试图运行echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile ,重新启动终端,并再次运行brew doctor,它仍抱怨同样的事情。我完全迷失在这里。有人可以用这个指导我吗?我究竟做错了什么?提前致谢。

+0

你使用'zsh',但修改'.bash_profile'。这可能不适合 –

+0

你可能安装了gcc,但你没有一个名为'gcc'的符号链接指向其中一个执行。选择你想要的gcc版本,并建立一个符号链接。例如'ln/usr/bin/gcc/path/to/cellar/gcc-4.8/gcc' –

+0

我跑了,'ln/usr/bin/gcc /usr/local/Cellar/gcc/4.8.3_1/bin/gcc- 4.8'并且它说'ln:/ usr/bin/gcc:没有这样的文件或目录'。我遍历到'/ usr/bin',并且我无法找到gcc –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值