C++ in mac pls help.
HI..I just learn C++ programming in my college. My college teach us using visual 6c++ , which is a window program. I'm using a macbook right now with Xcode . I'm trying to make C++ using xcode but couldn't built. it gives me this error "Command /usr/bin/gcc-4.0 failed with exit code 1" . So can tell me the solution for this or any other suggested program to do C++ .
This is just a normal C++ i'm testing with :
PLS Help ! Thx
I don't see anything wrong with that code. Did you copy & paste the code you're compiling or did you re-type it?
I sound like a jerk, but that's not C++, it's C. It still shouldn't cause any issue. What are the build settings on your IDE, or what's being passed into the command line?
std::cout << "Hello!" << std::endl;
From the looks of it, he might not have GCC installed. More info would definitely help.
Well. I'm also not sure whats the problem is. I just downloaded this Xcode3.1 . I just create a project C++ tool then add file C++ file with a.cpp . then i just wrote the program in there. I target the project and run then it will show me that error , if i din target it succeded but it din show me the output. it just says its succeded. Not sure whether that is a target or not, it is a round logo bottom for me to put a tick on it. And what is GCC?
I'm doing C++ on through xcode 3.1 too at the moment, so I might be able to help. From what I gather gcc is the Gnu C Compiler for C, C++ uses the g++ compiler.
When you click new project, you select the 'C++ Tool' option from the 'command line utility' template, then it comes up with the same code as you have there, just in C++
If you open up a terminal, you can type "gcc --version" or better yet "/usr/bin/gcc-4.0 --version" to see if you have gcc installed or not. I'd try "g++ --version" too.
But since XCode is trying to execute gcc and not g++, I'd say you're probably trying to compile the code as C. That's probably not a problem, since the code you posted is C and not C++. Just be aware of which language you're learning. :)
Well .. i don really understand.. i have another question. when it succeeded why it din show me the output ? how to see the output of my C ? how to execute to show the display like the visual 6 C++ ?
And to the question above i forget to say that i compile with no error but when i hit built and go then it gave me the error "Command /usr/bin/gcc-4.0 failed with exit code 1" . So whats the matter of this ?
Well, how did you get it to succeed?
Originally Posted by joequah
I played with xCode briefly, and everything I did was in GUI's with Cocoa(or whatever it is now). Is there something you have to set to do terminal programs in xCode?
When I do terminal programs on my Macbook Pro I use TextWrangler as my IDE and just use Terminal and gcc/g++ to compile/run the apps.
was C++ and
Never actually tried using < & > in C, always used quotations.
Angle brackets in #includes are C and C++. They mean "look for this header file in the standard places." Double quotes mean "look in the current directory for this header file, and if you don't find it, then look in the standard places." Basically, use angle brackets for built-in header file, and double quotes for your own.
At a guess: the compile worked, and when you ran it the console window flashed before you were able to see the output. (See the FAQ: Cprogramming.com FAQ > Stop my Windows Console from disappearing everytime I run my program?) "Build" didn't work because you don't have a project, you just have a single source file.
I'm not sure how good my guess is, but hey, it's a guess. :)
XCode does not automatically display the console when the application is executed. What's nice is that XCode logs the output, so the console may be opened after the fact, and you can view output from previous runs.
To see the output, you'll have to bring up the console, using Command-Shift-R, or select it from the Run menu.
Command-Alt-R executes the application.
ok... i did create a project . the problem now is i can only see the output of the project main.cpp with pressing the command+shift+r but i couldn't run file i create.
it gives me the error when i put a thick on there.
It sounds like you may have two conflicting main() functions in your application.
If you are adding a new file to the project and defining a main() function in it, then you should have a build error. You can either remove the default main.cpp file from the project or you can simply type your code into the main.cpp file. main.cpp is a good name for a file containing a main function anyway.