Question:
HelloWorld project under Windows & Linux (different?!)?
2009-11-07 12:56:47 UTC
I'm new to programming, and I started with c++; I used Visual Studio on Windows, that's how my project looked like:

#include
using namespace std;

int main ()
{

cout << "Hello World!" << endl;

return 0;

}

it worked perfectly.

i switched from windows to linux recently (i never really liked windows lolz)

- i installed the needed compiler [with yahooanswers help :)]
(sudo apt-get install build-essential)
- i installed VIM
- i opened VIM and changed the filetype to C++
I typed the same code like above inside the VIM editor, all fine till now.
- i save the file (HelloWorld.cpp)
- i open the terminal and type
"g++ HelloWorld.cpp", nothing happens, then i try
"g++ HelloWorld.cpp -o HelloWorld", same, nothing happens.


Since I'm new to Linux & Programming, obviously I'll do something wrong.

Can anyone tell me what I did wrong, or if I forgot something?

<<< pls dont recommend me some IDEs, i find it more fun just having to use an editor to program, lol >>>


thanks to everyone.
Three answers:
Mark aka jack573
2009-11-11 09:16:05 UTC
The only thing I can think of is that you do not have g++ on your system.



Download and install g++ if you do not have it.



it is funny that you don't seem to get any kind of error message. Some error messages that I would expect is that g++ could not be found, the HeloWorld.cpp could not be found.



Apart from that, check out the help or man pages about how to use g++.

man g++

may work, it has been a while since I used linux.
PhonicUK
2009-11-07 13:25:59 UTC
You should install Code::Blocks (apt get install codeblocks) which is a brilliant C/C++ IDE for Linux. Use it in place of Visual Studio and you'll have a much easier time of it all.
2016-10-16 04:34:05 UTC
nicely, I put in Linux - Ubuntu on my computer and locate it extra stable than abode windows. It runs swifter and needs not one of the consistent maintenance abode windows is plagued with mutually with defragging to illustrate. Defragging is in basic terms no longer required in Linux. Linux is likewise extra guard - as maximum malware is written for abode windows. i attempted having access to my computer and it relatively is ext3 partition from my abode windows Vista (NTFS) and it style of feels plenty harder than having access to yet another abode windows device. On my abode windows device, I constantly could desire to make effective that my anti-virus, anti secret agent ware and spyware utility is as much as this factor whilst my Linux computer has been working effective with none risk-free practices purposes. Linux isn't "hack evidence" even with the undeniable fact that it won't be able to ensue. i come across that Linux makes use of much less reminiscence and CPU aspects than abode windows. Linux is loose and there are different loose purposes available mutually with OpenOffice.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...