2011-12-22 5 views
3

gcc 4.6.2(GMP、MPFR、MPC)をダウンロードしてビルドを行いました。 build/gccディレクトリにg++実行ファイルがあります。gcc 4.6.2 OSX Lionでのインストール:「g ++:exec 'cc1plus'の実行中にエラーが発生しました」

私はそれを使用しようと

./g++ test.cpp 

私は次のエラーを取得する:

g++: error trying to exec 'cc1plus': execvp: No such file or directory

  1. どのようにこの問題を解決するには?

  2. デフォルトで新しく作成されたg ++を使用するにはどうすればよいですか?

PS。 これらの手順を実行してインストールしましたが、何のエラーも表示されませんでした。建てのMacOS X 10.7上でGCC 4.6.2を得る上

$ export CC=/usr/bin/gcc-4.2 
$ export CXX=/usr/bin/g++-4.2 
$ export CPP=/usr/bin/cpp-4.2 
$ export LD=/usr/bin/ld # not /usr/bin/gcc-4.2!! 

Clean also your $PATH as much as possible: 
$ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin 
(I don’t know exactly if this is necessary but works fine for me and when you close the Terminal the PATH reverts to its original setting). 

1. Download the GCC, GMP, MPFR, and MPC sources. The links are in the original post. 
2. Save everything in, say, ~/Downloads (or any directory you prefer). 
3. Start the Terminal and run the following commands (change the filenames according to the version you have downloaded): 
$ cd # go to your home directory 
$ mkdir src ; cd src 
$ tar -xzf ~/Downloads/gcc-4.6.1.tar.gz # change the path if you have saved the sources elsewhere! 
$ tar -xjf ~/Downloads/gmp-5.0.2.tar.bz2 
$ tar -xzf ~/Downloads/mpc-0.9.tar.gz 
$ tar -xzf ~/Downloads/mpfr-3.0.1.tar.gz 
$ cd gcc-4.6.1 
$ ln -s ../gmp-5.0.2 gmp 
$ ln -s ../mpc-0.9 mpc 
$ ln -s ../mpfr-3.0.1 mpfr 

4. Now create a build directory in ~/src but **outside** the gcc source tree, so that it can easily cleaned up to restart everything from scratch: 
$ cd ~/src 
$ mkdir build ; cd build 
$ ../gcc-4.6.1/configure 
$ make 
$ make install 

答えて

3

おめでとうございます - 私は(も、私はOKを建てたのだ4.6.1コンパイラで)成功しませんでした。私が何がうまくいかなかったかについてのメモがあれば、私は戦争の話をあなたと共有するでしょう。

GCCは特定の場所にインストールされるようにコンパイルされています(デフォルトでは/usr/localと思います)。ビルドエリアで実行しているときは、正しい代替ロケーションに実行ファイルを見つけるためにリダイレクトする必要があります。そのオプションがあります。

実行g++ --help。おそらく、-Bオプションが必要です。 ++ 4.6.1私のGは、この出力を与える:

$ g++ -print-search-dirs 
install: /usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/ 
programs: =/usr/gcc/v4.6.1/libexec/gcc/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/libexec/gcc/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/libexec/gcc/x86_64-apple-darwin11.1.0/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../../x86_64-apple-darwin11.1.0/bin/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../../x86_64-apple-darwin11.1.0/bin/ 
libraries: =/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../../x86_64-apple-darwin11.1.0/lib/x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../../x86_64-apple-darwin11.1.0/lib/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../x86_64-apple-darwin11.1.0/4.6.1/:/usr/gcc/v4.6.1/lib/gcc/x86_64-apple-darwin11.1.0/4.6.1/../../../:/lib/x86_64-apple-darwin11.1.0/4.6.1/:/lib/:/usr/lib/x86_64-apple-darwin11.1.0/4.6.1/:/usr/lib/ 
$ 

私はconfigureを実行したとき、私は--prefix=/usr/gcc/v4.6.1を指定しました。 (ヒント:設定した接頭辞はビルド時に存在しないか、パスにはシンボリックリンクが含まれてはいけません - GCCはコマンドラインで指定された値ではなくバイナリにシンボリックリンクを解決するため、これは、別のマシンでコードを使用する計画がある場合には重要です)。

+0

make installは、既存のg ++​​インストールには触れていないようです。私が 'print-search-dirs'を実行すると、デフォルトで4.2.1がすべて返されます。私のビルドはビルドと呼ばれるローカルディレクトリにあり、私はどのように進めるべきかわかりません。 'build/gcc/g ++ test.cc'を使ってサンプルプログラムをコンパイルしようとしたところ、問題のようなエラーが出ました。 – devnull

+0

コンパイル中にGCCが実行しているコマンドを見てみると、 '-B'オプションを使ってコンポーネントのどこにあるのかを指し示すことができます。あなたは同じことをする必要があります。あるいは接頭辞について言及していないので、 '/ usr/local'('/usr/local/bin/g ++ ')にあります。 '/ usr/local/bin 'が'/usr/bin'よりも先になるようにPATHを並べ替えることで、 '/ usr/bin/g ++'より優先して使うことができます。 (私のPATHにはシステムディレクトリの前に '/ usr/gcc/v4.6.1/bin'があり、' $ HOME/bin'ディレクトリとシステムディレクトリの前にあるものもあります)。 –

関連する問題