Xcode: stdio.h not found

Discussion in 'Mac Programming' started by maya90, Feb 17, 2011.

  1. maya90, Feb 17, 2011
    Last edited: Feb 17, 2011

    maya90 macrumors member

    Joined:
    Feb 16, 2011
    #1
    hi,

    from this tutorial
    http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/

    Code:
    #include <stdio.h> 
    int main(){ 
         printf("Hello World\n"); 
         return 0; 
     }
    
    to compile did:

    gcc program1.m -o program1

    got msg:

    stdio.h not found

    so searched for it... found here:

    /Developer/SDKs/MacOSX10.6.sdk/usr/include/

    so in program I put

    #include </Developer/SDKs/MacOSX10.6.sdk/usr/include/stdio.h>

    but got error on compiling... TONS of errors, too many to paste here...

    would appreciate some help..

    thank you..

    (PS: is there a "watch this thread" feature on these forums?? thank you...)
     
  2. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    You definitely missed something or your Xcode/gcc is not configured correctly.

    Please use the CODE tags around code you post, it makes things far easier to follow. You should NOT have the extra "#"s in the code. Use the "View plain" button on the site you are using to allow for easier copy & paste.

    Putting
    Code:
    #include <stdio.h>
    int main(){
        printf("Hello World\n");
        return 0;
    }
    
    in a file called program1.c on the Desktop and running
    Code:
    cd ~/Desktop
    gcc program1.c -o program1
    from Terminal.app works absolutely fine here.

    B
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Yes, thread subscriptions.
     
  4. maya90 thread starter macrumors member

    Joined:
    Feb 16, 2011
    #4
    oh -- you're saying it works on your machine? but it doesn't work in mine!! ;-)
    so what do I do.. I posted location of stdio.h... so: do I need complete path to it? how does compiler find it????

    thank you...
     
  5. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #5
    Investigate.

    Add the -v flag to gcc and post the actual output to the thread. Here's mine that works.

    Code:
    $ gcc -v deleteme.c -o deleteme
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5664)
     /usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1 -quiet -v -imultilib x86_64 -D__DYNAMIC__ deleteme.c -fPIC -quiet -dumpbase deleteme.c -mmacosx-version-min=10.6.6 -m64 -mtune=core2 -auxbase deleteme -version -o /var/folders/wx/wxyFEDIIEuO5W8FhK55-iE+++TI/-Tmp-//ccO7poKr.s
    ignoring nonexistent directory "/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include"
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/local/include
     /usr/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 (Apple Inc. build 5664) (i686-apple-darwin10)
    	compiled by GNU C version 4.2.1 (Apple Inc. build 5664).
    GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072
    Compiler executable checksum: bd1d5089add6fac25eedbd0768dee651
     /usr/libexec/gcc/i686-apple-darwin10/4.2.1/as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/wx/wxyFEDIIEuO5W8FhK55-iE+++TI/-Tmp-//cccNBdQI.o /var/folders/wx/wxyFEDIIEuO5W8FhK55-iE+++TI/-Tmp-//ccO7poKr.s
     /usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.6.6 -weak_reference_mismatches non-weak -o deleteme -lcrt1.10.6.o -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/folders/wx/wxyFEDIIEuO5W8FhK55-iE+++TI/-Tmp-//cccNBdQI.o -lSystem -lgcc -lSystem
    EDIT: You think perhaps it might have something to do with whatever you did to change the default location of Xcode? http://forums.macrumors.com/showthread.php?t=1097914

    B
     
  6. maya90, Feb 17, 2011
    Last edited: Feb 17, 2011

    maya90 thread starter macrumors member

    Joined:
    Feb 16, 2011
    #6
    ok, did what you said:

    gcc -v program1.m -o program1

    got all this:

    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5664)
    /Developer/usr/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/cc1obj -quiet -v -imultilib x86_64 -iprefix /Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/ -D__DYNAMIC__ program1.m -fPIC -quiet -dumpbase program1.m -mmacosx-version-min=10.6.4 -m64 -mtune=core2 -auxbase program1 -version -o /var/folders/GL/GLBogKRaEf8pr0pgc7wPIU+++TI/-Tmp-//ccoupYHv.s
    ignoring nonexistent directory "/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include"
    ignoring nonexistent directory "/usr/local/include"
    ignoring nonexistent directory "/usr/lib/gcc/i686-apple-darwin10/4.2.1/include"
    ignoring nonexistent directory "/usr/lib/../i686-apple-darwin10/include"
    ignoring nonexistent directory "/usr/include"
    #include "..." search starts here:
    #include <...> search starts here:
    /Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include
    /System/Library/Frameworks (framework directory)
    /Library/Frameworks (framework directory)
    End of search list.
    GNU Objective-C version 4.2.1 (Apple Inc. build 5664) (i686-apple-darwin10)
    compiled by GNU C version 4.2.1 (Apple Inc. build 5664).
    GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072
    Compiler executable checksum: 84137cc00ce86c64ee80a91a006f61ae
    program1.m:4:19: error: stdio.h: No such file or directory
    program1.m: In function ‘main’:
    program1.m:7: warning: incompatible implicit declaration of built-in function ‘printf’

    no idea what all this means... would very much appreciate some help.. (as posted previously, stdio.h IS there, it's at
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/

    actually it's at a lot of diff locations...
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/c++/4.2.1/tr1/stdio.h
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/secure/_stdio.h
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/stdio.h
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/xlocale/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/usr/include/fcgi_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/usr/include/secure/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/usr/include/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/usr/include/xlocale/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/c++/4.2.1/tr1/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/fcgi_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/secure/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/xlocale/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/c++/4.2.1/tr1/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/fcgi_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/secure/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/xlocale/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/c++/4.2.1/tr1/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/fcgi_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/secure/_stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/stdio.h
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/xlocale/_stdio.h
    /Developer/SDKs/MacOSX10.5.sdk/usr/include/fcgi_stdio.h
    /Developer/SDKs/MacOSX10.5.sdk/usr/include/secure/_stdio.h
    /Developer/SDKs/MacOSX10.5.sdk/usr/include/stdio.h
    /Developer/SDKs/MacOSX10.5.sdk/usr/include/xlocale/_stdio.h
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/tr1/stdio.h
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/fcgi_stdio.h
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/secure/_stdio.h
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/stdio.h
    /Developer/SDKs/MacOSX10.6.sdk/usr/include/xlocale/_stdio.h


    (and to reply to another poster, no, I have not changed location of Xcode install or anything else..)
     
  7. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #7
    Xcode didn't install properly. It should create all of those missing folders during install.

    Repair permissions for fun and then reinstall Xcode. http://guides.macrumors.com/Repairing_Permissions

    B
     
  8. maya90 thread starter macrumors member

    Joined:
    Feb 16, 2011
    #8
    oh brother.. I can't believe this..........:-(

    now I downloaded from here,
    https://developer.apple.com/devcenter/ios/index.action

    downoaded from this link
    Xcode 3.2.5 and iOS SDK 4.2
    on above page

    (now when I install I get a very diff install window from what's here,
    http://www.macworld.com/article/46286/2005/08/installxcode.html
    if you scroll down you will see a window "Install Xcode Tools" -- in my case what appears on this window is very different from what appears here..)

    (and yes something must be wrong b/c I also had to set path for gcc location, but I've read that the install puts gcc location in path for you...)

    thank you..
     
  9. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #9
    I would hope so. That page was for Xcode 2. Clearly what you installed even at first wasn't that.

    B
     
  10. maya90 thread starter macrumors member

    Joined:
    Feb 16, 2011
    #10
    ok, it finally worked!!

    thank you very much to all for your help..

    not sure what happened the first time around
     

Share This Page