Problem compiling C program

Discussion in 'iOS Development' started by giannaros, Oct 11, 2008.

  1. giannaros

    giannaros New Member

    Joined:
    Sep 1, 2008
    Messages:
    775
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Hi, I made a little program written in C on my iPod touch, but when I tried to compile it (using the command "gcc test.c"), it told me: " error: stdio.h: No such file or directory "
    The program's code was:

    #include <stdio.h>

    int main(void)
    {
    printf("Hello world!\n");
    return 0;
    }


    Can anyone help, please?

    Please Register or Log in to view images

  2. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch

    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
    printf("Hello World!\n");
    return (0);
    }
    Save that as Hello.c

    Then do
    Code:
    gcc Hello.c -o Hello
    Then
    Code:
    ldid -S Hello
    chmod 0755 Hello
    And Finally
    Code:
    ./Hello
  3. giannaros

    giannaros New Member

    Joined:
    Sep 1, 2008
    Messages:
    775
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    thats great that you were able to find that code on the internet. Now, learn what it means. you forgot to mention that unless he is compiling on iphone-gcc, that his compiler may be different. if you just open up OS X terminal and type gcc, you are basically only set to compile FOR OS X. also, if he isn't compiling with iphone-gcc, again, he will not have ldid handy(unless he compiled it for his current platform). as for setting permissions, when gcc compiles something, it automatically sets them to the required permissions to execute, in my understanding. For C and C++ programs, why not use g++?

    for iphone-gcc(i think you guys are using it)
    Code:
    g++ -c Hello.c -o Hello.o
    g++ Hello.o -o Hello -multiply_defined suppress -bind_at_load
  5. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    Wow, I think your jackass skills get sharper and sharper each day. and FYI, I typed that code, letter by letter, by myself =P
  6. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    in that case sweet! i'm glad you are learning

    Please Register or Log in to view images

  7. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    To prove it works....

    Code:
    iPod:/Apps/CStuff/HelloWorld root# gcc Hello.c -o Hello
    iPod:/Apps/CStuff/HelloWorld root# ldid -S Hello
    iPod:/Apps/CStuff/HelloWorld root# chmod 0755 Hello
    iPod:/Apps/CStuff/HelloWorld root# ./Hello
    Hello World!
    iPod:/Apps/CStuff/HelloWorld root#
    And..

    Please Register or Log in to view images

  8. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    just wondering if your using WinSCP3 then why use PUTTY aswell why not just open a terminal box by using Ctrl+T ??? just a thought or am I missing something here???
  9. cometobuy

    cometobuy New Member

    Joined:
    Jul 31, 2008
    Messages:
    369
    Likes Received:
    0
    you can run C in iphod ?
    yey

    Please Register or Log in to view images

  10. giannaros

    giannaros New Member

    Joined:
    Sep 1, 2008
    Messages:
    775
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    still doesn't work...

    Please Register or Log in to view images

    Please Register or Log in to view images

    Please Register or Log in to view images


    says it cant find string.h and stdio.h
    should I reinstall gcc???
    The stdio and string are not in usr/include!

Share This Page