Jump to content

Recommended Posts

Posted (edited)

I'm attempting to compile a hello world c programme on the mac terminal and getting the following errors:

mysource.c:1:19: error: /usr/local/include/stdio.h: Permission denied
mysource.c: In function main’:
mysource.c:2: warning: incompatible implicit declaration of built-in function printf

This is what I typed into the terminal (the name of the.c file is mysource):

MacBook-Pro:~ drummer014$ gcc mysource.c -o mysource

I had xcode 3 installed and received the same error, then I installed xcode 4.2 today and am experiencing the same issue. I'm using a MacBook Pro running Snow Leopard. I have tried typing gcc and then dragging the file into the terminal after following this scaler guide, but I still get the same issue. Any assistance would be highly appreciated.

I used the command gcc —verbose mysource.c -o mysource. What I got was as follows:

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-.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

 

Edited by WalidKhan
spelling, code and url correction
Posted (edited)

Open a normal terminal and use:

cat /usr/local/include/stdio.h

Does it work?

If you also have "Permission denied," open the terminal in administrator mode.

List contents of /usr/local and /usr/local/include to see if you have the right files there.

Finally, use the:

chmod -R 777 /usr/local/include/

-R should do it recursively with all files and subfolders.

(check the manual e.g. man chmod)

 

Before resolving the "Permission denied" error, there is no point in analyzing the rest of the messages..

 

You can use:

cd /usr/local

ls -l

or

cd /usr/local/include

ls -l

to see what permissions are assigned to files and folders.

chmod 777 filename means read+write+executable access for every administrator, user and guest (which is the weakest/dangerous one)

 

Refer to the manual:

https://man7.org/linux/man-pages/man1/chmod.1.html

 

Edited by Sensei

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.