1

Mac で C++ プログラムの「クリーン」ビルドを実行しようとしています。クリーンとは、明示的に指定していないものを含めないことを意味します。

私の gcc インストールは次の場所にあります。

/Applications/gcc471/

これまでのところ、次を使用してコンパイルできます

-nostdinc++

含めることによって

GPP-INCLUDES += -I/Applications/gcc471/include/c++/4.7.1/
GPP-INCLUDES += -I/Applications/gcc471/include/c++/4.7.1/x86_64-apple-darwin12.0.0

そしてやっている

g++ -c *.cpp $(GPP-INCLUDES) -nostdinc++

私はそれでかなり満足しています。ただし、私はコンパイルに飛躍しようとしています

-nostdinc

そして、私が含めたパスの数に関係なく、

/usr/local/include
/usr/include
....

次のようなエラーが大量に発生します。

/Applications/gcc471/include/c++/4.7.1/tr1/cmath: At global scope:
/Applications/gcc471/include/c++/4.7.1/tr1/cmath:156:11: error: ‘::double_t’ has not been declared
/Applications/gcc471/include/c++/4.7.1/tr1/cmath:157:11: error: ‘::float_t’ has not been declared
/Applications/gcc471/include/c++/4.7.1/tr1/cmath:160:11: error: ‘::acosh’ has not been declared
...

-nostdinc を使用して、Mac 上でゼロから cpp プログラムを完全に構築する方法を知っている人はいますか?

4

1 に答える 1

2

-nostdinc を使用してコンパイルすることはできましたが、-I/usr/include/ を使用せずにコンパイルすることはできませんでした。私は Xcodes llvm/clang/gcc4.2 (本当に古い) を信用していません/本当の GCC ナンセンスではありません。そこで、GCC を最初からダウンロードし、次のガイドを使用してソースからビルドしました: http://staticimport.blogspot.ca/2012/02/building-gcc-462-on-os-x-lion.html

問題は、libstdc が gcc に同梱されていないように見え、libstdc++ だけであることです。したがって、すべての .hpp ファイルは私の GCC ディレクトリにありますが、locale.h (1993 年以降) などの非常に古いヘッダーは、/usr/include への libstdc XCode インストールにのみ付属しているようです。インストールするバニラ libstdc を探し続けますが、今のところ、これらはコンパイルに含めることができる最も最小限で最も「GNU」なディレクトリです。

...
#FOR -nostdinc++ 
GPP-INCLUDES += -I/Applications/gcc471/include/c++/4.7.1/
GPP-INCLUDES += -I/Applications/gcc471/include/c++/4.7.1/x86_64-apple-darwin12.0.0
#for -nostdinc
GPP-INCLUDES += -I/Applications/gcc471/lib/gcc/x86_64-apple-darwin12.0.0/4.7.1/include/
GPP-INCLUDES += -I/usr/local/include
GPP-INCLUDES += -I/usr/include/ #bahhhhh cant get away

g++ -c *.cpp $(GPP-INCLUDES) -nostdinc++ -nostdinc  -std=c++11
于 2013-10-23T18:34:10.960 に答える