我正在尝试在 mac 终端中编译一个 hello world c 程序,我正在生成这些错误:
mysource.c:1:19: error: /usr/local/include/stdio.h: Permission denied
mysource.c: In function ‘main’:
mysource.c:3: warning: incompatible implicit declaration of built-in function ‘printf’
这是我在终端中输入的内容(mysource 是 .c 文件的名称):
MacBook-Pro:~ drummer0014$ gcc mysource.c -o mysource
我安装了 xcode 3 并产生了同样的错误,所以我今天刚刚安装了 xcode 4.2 并且遇到了同样的错误。我在运行雪豹的macbook上。我还尝试输入 gcc 然后将文件拖到终端中,以便它具有完整路径,但我得到了同样的错误。任何帮助将不胜感激。
当我输入 gcc --verbose mysource.c -o mysource 这是我收到的内容:
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~3/src/configure --disable- checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --enable- llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~3/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/cc1 -quiet -v -imultilib x86_64 -iprefix /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/ -D__DYNAMIC__ mysource.c -fPIC -quiet -dumpbase mysource.c -mmacosx-version-min=10.6.8 -m64 -mtune=core2 -auxbase mysource -version -o /var/folders/7r/7rMZhHx3F0WhnoyEK1zUgE+++TI/-Tmp-//ccaqeJkd.s
ignoring nonexistent directory "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include"
ignoring nonexistent directory "/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include
/usr/local/include
/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) (i686-apple- darwin10)
compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072
Compiler executable checksum: e787fa4ffdc9e78ad5e913828c220d85
mysource.c:1:19: error: /usr/local/include/stdio.h: Permission denied
mysource.c: In function ‘main’:
mysource.c:3: warning: incompatible implicit declaration of built-in function ‘printf’