How do i view the C++ program i just made in Xcode? I'm a beginner

Discussion in 'Mac Programming' started by AustinWhite, Sep 11, 2011.

  1. AustinWhite macrumors newbie

    Joined:
    Sep 11, 2011
    #1
    i just programmed my first "Hello world" Application in Xcode. so i ran the program and there were no errors but when i try to open the product all i see is a window with a grey box in the center that says "exec" in the top left of it. am i doing it wrong? I'm confused.

    i just started teaching myself C++ today and i have absolutely no programing experience, so excuse my ignorance please
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    Every program has an icon. The program you created was most likely a "command line program" and the grey box with "exec" inside is the icon that the Macintosh uses for command line programs. So that is absolutely what is expected.

    Command line programs don't contain any code to show them in a window. So if you double click it in the Finder you won't see anything that it does. You can start it from XCode (Command-R) or start the Terminal application and use standard Posix commands to start it. You'll probably want to run it from XCode.

    Telling us which XCode version you are using is very helpful, because different versions of XCode behave different.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    Which book or tutorial you're learning programming from? Be specific: title & author, or the URL of the online tutorial.
     
  4. robvas macrumors 68020

    Joined:
    Mar 29, 2009
    Location:
    USA
    #4
    You need to view the console window by hitting Shift-Command-R or going to the 'Run' menu and choosing 'Console'

    [​IMG]

    [​IMG]
     
  5. AustinWhite thread starter macrumors newbie

    Joined:
    Sep 11, 2011
    #5
    the book is called "Sams Teach Yourself C++ in One Hour a Day" by Jesse Liberty, Siddhartha Rao, and Bradley Jones

    It seems like a pretty informative book so far

    ----------

    I'm using the latest Xcode, 4.1.1 i believe.

    so is there a different place in Xcode where I'm supposed to write a C++ program or is command line the right place to be.

    Also, is Xcode the compiler that most people use on mac? or is there others that work better
     
  6. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #6
    In XCode 4, you need to show the console in the debug area. The easiest way to do that is to Shift+Command+C.
     

    Attached Files:

  7. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #7
    Your "Teach yourself C++" book will be just about learning the C++ language, and that will work best if you start in XCode with "New Project", then choose the "MacOS X / Applications / Command Line Tools" project, and then use Command-R to run it. Everything you learn there can be applied to any other computer (Linux, Windows, etc. ) using C++ as well.

    Other templates like "Cocoa Application" would be what you eventually use to write applications, but you'll need a lot more knowledge to use them successfully, so that's not a good way to start.

    And all the Apple software is created with XCode, so you are in good company there. The whole of MacOS X, and iOS, and all of Apple's own applications. Plus everything you can buy on the App Store for iOS or MacOS X.
     
  8. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    Based on what? That book has no information at all on Xcode. So to learn anything about Xcode, your primary tool, you'll need another resource entirely. At the very least, find an Xcode 4 tutorial, or find another book that will teach you Xcode 4.

    Also, why C++? If your goal is to write Mac programs, that's not the primary language; Objective-C is. And there's not nearly enough similarity between the two languages, that learning one will help you much when learning the other.
     
  9. AustinWhite thread starter macrumors newbie

    Joined:
    Sep 11, 2011
    #9
    The book is written in a way that anyone on any platform can learn from it. there aren't many books that I've seen that are about learning C++ in Xcode.

    and by the way I'm not just trying to learn how to program mac programs, I'm trying to learn how to program in general, wether it be on a mac or pc. i picked C++ because it seems like a good place to start, after that i was going to learn Objective C and then lean some other languages if i like it
     

Share This Page