我正在尝试在我的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程序?
答案 0 :(得分:1)
我能够使用-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年开始),似乎只有libstdc XCode安装到/ usr / include。我会一直在寻找一个vanilla 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