C++ & linux - newbie
I just started teaching myself c++ and have been doing most of my compiling on a windows machine. I thought I would give it a try with linux but am having problems.
The standard #include <iostream.h> int main() { cout << "Hello World!" << endl; return 0; } wont compile. I have seen posts about dropping the h from the iostream and "include namespace std" but none of that seems to work either. I though c++ was supposed to be pretty platform independant. I really dont want to have to learn to code one way for windows and another for linux. |
compiles on my machine code is correct what is the command u are using to compile
|
just gcc. suing version 3.2.2-5
|
g++ is the command you want to use.
|
That did it thanks!
|
If you want to make GUI programs, try using Qt - free and simple :)
|
Quote:
|
my basis for recommending it is it drastically simplifies string handling etc, and it's tutorials are relatively good.
also, great book is "Learn C++ for linux in 21 days" :) |
I am using "teach yourself c++ in 21 days". But thanks for the info on qt, I will definately check it out once I get through the basics.
|
Quote:
A great book that I recommend (along with the others mentionned which I also have) is Tom Swan's 'GNU C++ for Linux'. Until I had found that book I had been rather frustrated by the windows-centric leanings of the other books (although that's a minor gripe since by and large, C++ is C++ for the basics). This book is totally awesome for the beginner programmer using linux. If you have to choose only one book, that's the one I'd go with. |
Well, I tried compiling your 'hello world!' code with gcc (>gcc test.cpp) and got a whole load of linker errors. I'm hardly an expert myself and I'm not sure why they're there.
Just using the c++ compiler worked fine (>c++ test.cpp), although you will need to add the 'using namespace std' into your code. That might do you for a while but you really should be able to use gcc. What distro do you use (I'm using mandrake)? Anyone else out there that's cleverer than me care to shed some light on the situation? |
wow, posts come thick and fast here don't they!
|
A 5.5 hour gap is fast? :confused:
|
Quote:
So am I correct in assuming gcc is for c programs? |
Quote:
|
All times are GMT -5. The time now is 07:08 PM. |