已安装GCC,但未找到命令
我是linux新手,我很难让它工作。 我卸载并安装了几次gcc。现在,当我运行已安装GCC,但未找到命令,gcc,zsh,gcc-warning,oh-my-zsh,Gcc,Zsh,Gcc Warning,Oh My Zsh,我是linux新手,我很难让它工作。 我卸载并安装了几次gcc。现在,当我运行gcc--version时,它仍然显示zsh:command not found 当我转到/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-
gcc--version
时,它仍然显示zsh:command not found
当我转到/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
我运行了“brew医生”,得到以下输出
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
,但它仍然会出现同样的问题。我在这里完全迷路了。有人能用这个来指导我吗?我做错了什么?提前感谢。您没有配置正确的配置文件。看看这个:
检查gcc是否正确安装:
brew install gcc
brew link gcc48
创建brew创建的链接的别名,并将其放入.zshrc中
cd /usr/local/bin
ls cpp*
ls c++*
alias gcc=/usr/local/bin/<whatever_link_you_found>
cd/usr/local/bin
ls cpp*
ls c++*
别名gcc=/usr/local/bin/
您正在使用zsh
,但要修改.bash\u配置文件
。这可能不适合您可能安装了gcc,但您没有一个名为gcc
的符号链接指向其中一个。选择您想要的gcc版本,并创建一个符号链接。e、 g.ln/usr/bin/gcc/path/to/cillar/gcc-4.8/gcc
我运行,ln/usr/bin/gcc/usr/local/cillar/gcc/4.8.3\u 1/bin/gcc-4.8
它说ln:/usr/bin/gcc:没有这样的文件或目录。我访问了/usr/bin
,但找不到gcc。为什么要标记[linux]?谢谢,这帮助我解决了路径问题。但仍然无法链接gcc:(运行which gcc
和gcc--version
。这两个命令的输出是什么?您使用的发行版是什么?它说gcc not found
。我想我必须像前面的注释一样创建一个符号链接。我也尝试过这么做。。参考我上面的注释等一下,我想您解决了路径问题了吗?切换到bash(`bash'))然后运行相同的两个命令,我得到了相同的输出