+ Reply
Results 1 to 4 of 4
  1. #1
    What's Jailbreak?
    Join Date
    Oct 2008
    Location
    Northern Ireland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hello, world! in C++ Dilemma

    Hey,

    New member here because I haven't been able to find any good info on how to create C++ programs for the iPhone/iPod Touch.

    I just want to make a simple "Hello, world!" programme on the iPod itself and <b>not</b> using the toolchain.

    I found a thread discussing how to do it in C

    Code:
    //main.c
    #include <stdio.h>
    
    int main()
    {
    printf( "Hello, world!n" );
    return 0;
    }
    then type into terminal

    Code:
    gcc main.c -o main
    ldid -S main
    chmod 0775 main
    ./main
    and that works perfectly but when I try to make a C++ "Hello, world!" I get header errors.

    Code:
    // main.cpp
    #include <iostream>
    
    int main()
    {
    std::cout << "Hello, world!n" << std::endl;
    return 0;
    }
    Now, when I type into terminal:

    Code:
    g++ main.cpp -o maincpp
    I get the following errors;

    Code:
    main.cpp:1:20: error: iostream: No such file or directory
    main.cpp: In function 'int main()':
    main.cpp:5: error: 'cout' is not a member of 'std'
    main.cpp:5: error: 'endl' is not a member of 'std'
    Please could someone help me out with this problem as I want to learn how to program in C++ but because I have lots of homework during the evenings I don't get much time to use a C++ compiler on my desktop.

    I would also prefer to code in C++ because I've already got to grips with the basics and don't really want to learn C.

    Thanks.
    Last edited by decky1990; 10-30-2008 at 04:01 AM.

  2. #2
    What's Jailbreak?
    Join Date
    Oct 2008
    Location
    Northern Ireland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Come on people, there are bound to be some good programmers out there who can help me.

  3. #3
    iPhone? More like MyPhone
    Join Date
    Oct 2007
    Posts
    132
    Thanks
    2
    Thanked 18 Times in 15 Posts

    Clearly you are missing STL header files.

    Once you install the missing headers, you have to ckeck if the lib is installed.

  4. #4
    What's Jailbreak?
    Join Date
    Oct 2008
    Location
    Northern Ireland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the standard library files are not missing they are just in other subfolders within /var/include

    Problem is whenever I try to link the compiler to the directory I get everlasting errors. The compiler finds iostream alright when I link it using the -I"/var/include/c++/4.0.0/" option but it can't find the header files stated within iostream.

    Another question: am I searching for iostream or iostream.h? And which compiler should I be using e.g. gcc, c++, g++, arm-apple-darwin9-g++ etc?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts