Sono in esecuzione os x versione el capitan e ho installato gcc5 tramite homebrew. Tuttavia, compilando programmi semplici come:
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
porta al seguente errore:
hello.c:1:19: fatal error: stdio.h: No such file or directory
compilation terminated.
Questo è il caso di qualsiasi altra libreria c standard, come ad esempio time.h.
Ho letto in merito a dove gcc sembra collegarsi alla libreria e secondo https://stackoverflow.com/questions/17939930/finding-out-what-the-gcc-include-path-is posso ottenere l'elenco nel modo seguente:
echo | gcc-5 -Wp, -v
Che si traduce nei seguenti percorsi:
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.2.0/libexec/gcc/x86_64-apple-darwin14.4.0/5.2.0/lto-wrapper
Target: x86_64-apple-darwin14.4.0
Configured with: ../configure
--build=x86_64-apple-darwin14.4.0 --prefix=/usr/local/Cellar/gcc/5.2.0
--libdir=/usr/local/Cellar/gcc/5.2.0/lib/gcc/5
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-libstdcxx-time=yes
--enable-stage1-checking --enable-checking=release --enable-lto
--with-build-config=bootstrap-debug --disable-werror
--with-pkgversion='Homebrew gcc 5.2.0'
--with-bugurl=https://github.com/Homebrew/homebrew/issues
--enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 5.2.0 (Homebrew gcc 5.2.0)
Facendolo per il compilatore os x gcc, ottengo quanto segue:
clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target
x86_64-apple-darwin15.0.0
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"
ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
include "..." search starts here:
include <...> search starts here: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks
(framework directory)
End of search list.
Non so che cosa significano questi output, né dove si trovano le mie librerie standard. Qualcuno potrebbe aiutarmi a configurare correttamente gcc5?
xcode-select --install