help with VI and gcc T_T
iv'e already installed gcc, im trying to compile my hello_world.cpp but it produces an error(is my command correct -->> "[dinglej@localhost bin]$ gcc hello_world.cpp")...wah..dunno what's wrong with my set-up...here's the error...
hello_world.cpp: In function `int main()': hello_world.cpp:5: error: `cout' undeclared (first use this function) hello_world.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.) help pls.. |
You should use g++ to compile C++ code. Also, did you remember to put "using namespace std;" or use std::cout? Modern C++ compilers expect that the correct namespace (std) be used.
|
lol...there's something wrong with my command...bwahahah...the correct command to use is...
[dinglej@localhost bin]$ g++ sample.cpp -o sample then run it using this command... [dinglej@localhost bin]$ sample hahahah...nyay :D |
post your code. Sounds like stdio.h is not included.
Edit: just re-read the post. I'm just an old perl / c programmer, so not sure if that's needed for c++, so ignore this post. |
here's my code
#include <iostream> int main(){ std::cout << "Hello World!" << std::endl; return 0; } i now know how to compile...nyehehe...my command was so so so wrong...nyay...thank you everyone..bwahaha...funny me.. :D |
I just copied your code to a text file, added a newline to the end, and used the commmand:
g++ hw.cpp -o sample and got a good compile ./ sample properly printed out the "Hello World" statement So, I don't think it's a problem with your code, something is missing in your install. I'm not a c++ programmer, so guess I'll leave it to the experts. |
All times are GMT -5. The time now is 12:10 AM. |