C++ and Xcode

Discussion in 'Mac Programming' started by Epprecht, Nov 6, 2005.

  1. macrumors newbie

    Aug 13, 2005
    Hi, I'm a student learning C++, new to macs and xcode. Here's my situation: I begin a new project, choose C++ tool from the Command Line Utility Group, then write the source code. I click the build and go button and it compiles fine but will not execute. I keep getting [Session started at 2005-11-07 00:42:23 -500.] or http://i3.photobucket.com/albums/y71/swissgnr/Picture1.png and thats it. A friend of mine who uses Xcode and does C++ cannot figure out why I keep getting this. I'm not sure if it is something I'm doing wrong or what. If anyone could help it would be much appreciated.
  2. macrumors 6502a


    Jun 3, 2004
    east of the West and west of the East
    Welcome to MacRumors Forums!

    What is your code supposed to be doing? It appears as though it is running, but there are no I/O prompts.
  3. macrumors 68000


    Oct 27, 2003
    Post a code and I'll give a looksee. No Promises though, I'm no expert on C++ under OSX, but I want to be :D

  4. Guest


    Feb 17, 2003
    Hitchin, Herts, UK
    That the 'Run' button is visible suggests your program isn't actually running in that screenshot - otherwise the button would say 'Terminate' and be a red stop sign.
  5. thread starter macrumors newbie

    Aug 13, 2005
    Here is a screenshot of my source code; http://i3.photobucket.com/albums/y71/swissgnr/source.png This program is one that I had earlier this year and completed. I've used two C++ compilers before called Cygwin and Dev++, both compile and execute the program fine. So, I'm not sure if the problem is with my code or I'm not doing something right in Xcode.
  6. thread starter macrumors newbie

    Aug 13, 2005
  7. macrumors member

    Nov 13, 2005
    I am new to macs and have no idea about Xcode, but I think it means it could not find the executable you think you've just compiled/built.
  8. Moderator emeritus


    Jun 15, 2000
    Try cleaning the project. Then quit Xcode, and recompile the project. Should work (I got this exact same error a few days ago also).
  9. macrumors 6502

    Nov 10, 2005
    New South Wales, Australia
    I've been using Xcode for ages for Cocoa development and didn't know you could do what you're trying to attempt. I usually use the terminal ;)

    Well, I just tried your code, and it works for me (using Xcode). Do you have problems with other projects?
  10. macrumors newbie

    Nov 7, 2005
    Voronezh, Russia
    I don't knkow - if it is a bug or something else, but... you need to output '\n' at the end of the line.
    Try the following code in the first cout << ...
    cout << "Enter the length of the block (in meters)..."[B] << endl[/B];
    May be it is a flushing problem of the output stream...
  11. macrumors newbie

    Nov 14, 2005
    Very Same Problem

    Im having the very same problem with the xcode tools about trying to run the program. It just says "[Session started at 2005-11-14 21:25:27 -0700.]" and nothing happens, i even try to click RUN like thousands of times and it just sits there i tried to use the help file and that didnt help for anything, and I didn't notice anything that helped the other person about his problem. Im just new to programing and dont get anything but here is my .cpp file
    // Program to convert tempurature from Celsius degree
    // units into Fahrenheit degree units:
    // Fahrenheit = Celsius * (212 - 32)/100 + 32
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    using namespace std;

    int main(int nNumberofArgs, char* pszArgs[])
    // enter the tempurature in Celsius
    int celsius;
    cout << "Enter the tempurature in Celsius:";
    cin >> celsius;

    // calculate conversion factor for Celsius
    // to Fahrenheit
    int factor;
    factor = 212 - 32;

    // use conversion factor to convert Celsius
    // into Fahrenheit values
    int fahrenheit;
    fahrenheit = factor * celsius/100 + 32;

    // output the results (followed by a NewLine)
    cout << "Fahrenheit value is:";
    cout << fahrenheit << endl;

    // wait until user is ready before terminating program
    // to allow the user to see the program results
    return 0;
  12. macrumors 6502a


    Jan 8, 2004
    I pasted it in my xcode and it worked.
  13. Moderator emeritus


    Jun 15, 2000
    I'm pretty sure it's an Xcode problem, not a code issue. Have you tried cleaning the project, and/or relaunching Xcode?
  14. macrumors 6502a


    Aug 22, 2003
    Also try running your binary from the terminal. Looks like xcode screwed up its i/o redirect.
  15. thread starter macrumors newbie

    Aug 13, 2005
    I have tried cleaning the project and reopening it and it didn't work. Maybe I did not install xcode properly or something. Also, how would I try running my binary from the terminal? I'm still not sure how to do many things with xcode. Thanks
  16. macrumors 6502a


    Jun 3, 2004
    east of the West and west of the East
    I may have found your problem. Your project name in the first instance seems to be named "mow.cpp" so your executable ends in ".cpp"; this appears to confuse XCode. I tried naming my project similarly and it produced the problem you're having.
    Rename your project w/o ".cpp", build and see if it works.
  17. macrumors newbie

    Nov 14, 2005
    Found something else

    I talked to my friend about this and he also said that his xcode just ran it fine and he found me a 3rd party software to compile the c++ code which worked for me perfectly.
    (just in case someone else had this problem here is a quick solution)
  18. macrumors member

    Mar 23, 2004
    Did you try selecting "Standard I/O Log" from the "Debug" Menu?
  19. thread starter macrumors newbie

    Aug 13, 2005
    Yay! First, thank you Whyren, it did work not including the .cpp to the filename. I was used to adding the .cpp but I'm learning. I3AnThRaX69, thanks for the alternative and thanks to everyone else for the help! This thread was a my first post on MacRumors: Forums after lurking around for quite a while and it's a good place. danke
  20. macrumors 68000


    Feb 1, 2005
    Seeing this first time, it won't work properly because system("PAUSE"); does not exist on Macs.

Share This Page