ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, I need to learn in the next 15 days C++ completly (and I'm going to start A.S.A.P, I know other lang so it's just about the syntax different, right?)
I need to ask a few things first though :
1) What should I know as basic info when using C++ in linux?
2) Is there any difference between CPP in lin/win?
3) What is the recommended compiler in linux?
4) What is unique in C++, why was there even a need for this language? (Why didn't C was enough?)
5) Do you think I should know anything else? what?
>I need to learn in the next 15 days C++ completly
dont you hate when you have to lie on an application for employment
>1) What should I know as basic info when using C++ in linux?
well you should know how to use g++ from the command line, including how to include header paths, and library locations.
>2) Is there any difference between CPP in lin/win?
there is no difference in c++ itself, however there are differences in compilers, headers, and os api.
>3) What is the recommended compiler in linux?
GCC's g++
>4) What is unique in C++, why was there even a need for this language? (Why didn't C was enough?)
are you serious.. this sounds like homework now.. but i guess it is summer.. c++ add the ability to easily write object oriented code, along with some other additional enhancements that you can read about.
>5) Do you think I should know anything else? what?
yeh there was one other thing, but i cant think of it now. hehe. no seriously though. 15 years probably wouldnt be enough let alone 15 days. just find some tutorials on the web and start coding.
>I need to learn in the next 15 days C++ completly
dont you hate when you have to lie on an application for employment
>1) What should I know as basic info when using C++ in linux?
well you should know how to use g++ from the command line, including how to include header paths, and library locations.
>2) Is there any difference between CPP in lin/win?
there is no difference in c++ itself, however there are differences in compilers, headers, and os api.
>3) What is the recommended compiler in linux?
GCC's g++
>4) What is unique in C++, why was there even a need for this language? (Why didn't C was enough?)
are you serious.. this sounds like homework now.. but i guess it is summer.. c++ add the ability to easily write object oriented code, along with some other additional enhancements that you can read about.
>5) Do you think I should know anything else? what?
yeh there was one other thing, but i cant think of it now. hehe. no seriously though. 15 years probably wouldnt be enough let alone 15 days. just find some tutorials on the web and start coding.
good luck
haha//
Thanks dude,
anyways
> g++ from the command line, including how to include header paths, and library locations.
can you give an example?
user : g++ file.cpp fileout
?
what about the headers?
isn't it much easier to use a GUI compiler that points you out to where the problem (if there's one), is [why it doesn't compile, etc]??
>dont you hate when you have to lie on an application for employment
No man. I wasn't lying, to anyone. they just wanted me to learn cpp in the next 15 days (not as a guru, but atleast understand the language).
yeh an example would be if you are writing and linking somthing to SDL. you would have to do something like. (ignoring the existance of sdl-config)
g++ -I/path/to/SDL/headers -L/path/to/SDL/LIBS -lSDL -lSDL_image file.cpp
so you should know how to add those locations of non standard headers with -I and nonstandard libs with -L and then specify the necessary libs with -l. that stuff is elementary, have to know it. along with other g++ command line options.
>isn't it much easier to use a GUI compiler that points you out to where the problem (if there's one), is [why it doesn't compile, etc]??
whoooaaa. do you know what kind of argument you will start with a statement like that .. either way you go, with cmd line, or gui you will get pointed to wehre the problem is. the ide does nothing special above what gcc/g++ does, it just wraps the output in a pretty package. from the cmd line you will get filename and line number.
imo you should start out on the cmd line, and get to know all about g++/gcc.. esp if you only have 15 days. you should spend 14 on the cmd line and 1 in an ide. unless you know what ide they will have you using and if you can get ahold of that you may be further ahead to use it for 15 days..
>No man. I wasn't lying, to anyone. they just wanted me to learn cpp in the next 15 days (not as a guru, but atleast understand the language).
thats the first thing that popped into my head, because everytime i have lied on one, i had to run home and learn somthing new. accelerated education at its best.
also to follow up on the examples of command line stuff you should know. you should also have knowlege of how large project are compiled. like compiling to object files and then linking everything together. and you should also read up on using libraries.
Don't laugh, but I'd also suggest picking up a copy of "C++ for Dummies." It does an excellent job of taking you through the command line topics. (FYI - I had a C++ course in college, which was crap. I learned more about the fundamentals of C++ from this book than from that course). Anyway, the book comes with a CD which has a copy of the GNU compiler, though I believe it is the Win32 version. You can easily download the Linux version on the web. The CD also includes example code from the book. I wouldn't base everything you're learning on it - you would definitely benefit more by finding tutorials on the web - but I would definitely recommend it as a good starting point or as a reference tool.
Last edited by IndianaTux; 06-30-2006 at 11:10 AM.
4) What is unique in C++, why was there even a need for this language? (Why didn't C was enough?)
I'm sure I'm going to miss something here but C++ was added to provide different paradigms to support the programmer. That means you need to be comfortable with those ways of thinking. So there is procedural programming (just as there is in C) then there is object-oriented programming (classes, objects, inheritance, encapsulation, polymorphism), next comes generic programming (templates) Then there is modular programming (header files, namespaces & exceptions).
I think that's it, but maybe I forgot something. It may be possible to learn the syntax in 15 days but not to understand its meaning.
Do you have a question about this? You use "g++ hello.cpp", but then the executable will be called a.out. If you want to choose what the executable is called, use g++'s o option: "g++ hello.cpp -o hello" will create an executable called hello.
all is the default done when you type make and hit enter, and this links the object file(s) into an executable
g++ -c compiles to an object file g++ -o links object files into an executable
If you leave out the name in g++ -o name $(obj) (here it is $(exe)), your executable will be named a.out
in the line hello.o: hello.cpp , hello.o is the name of the file built, and any names following the : are files it depends on (here, hello.cpp). The next line is a tab, followed by the command to build hello.o from hello.cpp.
all is the default target as I said earlier, and depends on the object files $(obj) (in this case, hello.o)
The target clean has no dependencies, and the - in front of the rm tells make to not bail out if a file can't be deleted (ie, say you want to clean out all the object files from a failed build that didn't produce an executable, you can still type make clean)
You could also call all anything you want... ie, you could change it to love, and then build your executable using make (assuming love is the first target) or make love.
If it's a really basic program like a "hello world", is there really any need to use a makefile?
Like I said, I'm going to use more then a basic use,
So I need to know what it's best to do even when it comes to more complicated programs!
Anyways, I liked g++ (very similar to gcc)..
but I'd like to have also, as a backup, GUI compiler...
what's the name of the best GUI compiler for C++??
maybe have a look at kdevelop. It uses gcc/g++ (actually the same compiler package). I haven't any experience with it, though.
Also have a look at the qt - Designer, if you want to design a GUI frontend. But this may be included in the kdevelop.
Drawback: You may be relying a bit to much on kde libraries. Another GUI package could be the GTK like libraries like used ont the GNOME window manager.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.