July 12, 2007 4:28 PM   Subscribe

I want to learn c++ from the ground up. Help me use c++ without the use of an IDE.

I want to write c++ in notepad so I can learn the advantages and convenience of using an IDE. I know I need a compiler, debugger and development environment. Where can I get all of these, and it would be helpful to know how to download them (some downloading descriptions are so complicated). Also, will these show up in the add/remove programs in xp or will they just be in the directory?
posted by amsterdam63 to Computers & Internet (28 answers total) 8 users marked this as a favorite
You can do c++ compiles from the command line with gcc in cygwin.

Some people think IDEs are great. Some don't.
posted by DarkForest at 4:47 PM on July 12, 2007

There's also visual c++ express free from microsoft, though I don't know if it includes a command line compiler.
posted by DarkForest at 4:48 PM on July 12, 2007

Could you say more about your end goal?

Do you want to be a wizard with C++? A wizard with an IDE? A wizard with C++ and some IDE? Is it either/or or both/and? Is programming on XP a must? What applications do you want to create, or are you more interested in the programming for its own sake?

I work in a mixed-language, multi-platform shop. Because of how the languages were designed, the real IDE wizards are, without exception, programming in Java. The real C++ wizards are, almost without exception, working in either Vim (direct Windows download; will show up in add/remove programs) or Emacs (direct download; will show up in add/remove programs). Both of those programs are text editors, though, and not fullblow IDEs.

When asked to recommend a C++ IDE, almost all the C++ers recommend SlickEdit. It's a commercial product and you need to have session on their site to download a demo, so I can't give you a direct link.

Getting set up to do barebones C++ on Windows is actually pretty difficult, in my experience. Pretty much nothing is simple when it comes to C++. Were I trying to do it, I'd install Cygwin (setup.exe download; still kind of involved to actually get running) and then grab gcc (a compiler) and gdb (a debugger). The downside of this is that you're not really doing Linux programming and you're not really doing XP programming. The reasons I recommend this given all of that are
  1. You don't have to install Linux; and
  2. It's a lot easier to start from the beginning with C++ if you take Windows out of the equation.

posted by amery at 4:55 PM on July 12, 2007

If you go with cygwin, be aware that the setup program is less helpful than it might be for a new user. You'll want gcc (core), g++ (the c++ compiler), and gdb (the debugger). I believe that cygwin simply exists in its directory and to uninstall it, you just remove the directory. The cyugwin setup faq is here.
posted by DarkForest at 4:56 PM on July 12, 2007

Response by poster: I know IDE's are great. I think a better way to explain my question would be to say I want to learn how IDE's work by seeing all the seperate parts work. I'm not really sure why a development environment or platform is needed.
posted by amsterdam63 at 4:56 PM on July 12, 2007

Response by poster: also this is probably another topic, but for some reason my command line isn't working. It just says "is not recognized as an internal or external command, operable program or batch file" no matter what I type in.
posted by amsterdam63 at 4:58 PM on July 12, 2007

Does Slickedit have some integrated debugging facility? I'm not sure I'd call it an IDE without that. I thought it was just an editor with some project management capabilities. I've run across one or two SlickEdit fans, but it's hardly unanimous. Most I've met working in windows just use visual studio (unless they're cross compiling to another target).
posted by DarkForest at 5:03 PM on July 12, 2007

Response by poster: So to do barebones c++, working with linux (Ubuntu) would be much easier to do?
posted by amsterdam63 at 5:04 PM on July 12, 2007

An IDE is really not necessary at all. Many projects are built on makefiles and the developers use a separate debugger, and whatever editor. ctags or some equivalent can provide tags for some of the fancier navigation through the code.
posted by DarkForest at 5:05 PM on July 12, 2007

VC++ Express should include the command line compiler. If it doesn't, the Platform SDK might. If it doesn't, the DDK (driver development kit) definitely does. This is definitely an option, but MSVC was never really meant to be used from the commandline, and you'll go moderately insane with all the switches.

Cygwin or MSYS (Minimal SYStem) are great alternatives to get a unix-like environment to develop in. Both have installers, and should register with Windows like any other app.

I'd recommend using something like TextEdit or Notepad++ so you at least have syntax highlighting and indentation. Very few people program without these. Eventually, if you decide you don't need an IDE, vim and emacs are the two unix classic big boys when it comes to programmers' editors, although many more are around and may suit you better.

If you're on Cygwin/msys, you should learn about makefiles very early on.

If you're on cygwin/msys, you should avoid the GNU autotools until you're comfortable with make by itself.

GDB is a pain to use as a debugger (its for gcc). WinDBG, which should be distirbuted with the platform SDK (its for MSVC), isn't bad. DDD, a graphical frontend for GDB, is also not bad. If you use emacs, gdb will run inside emacs.

In terms of the development environment, if you use a microsoft compiler, you'll open up a cmd.exe environment from the start menu that will have all the paths set up, so you can simply type cl and away you go. If you use cygwin or msys you'll be dropped into a bash shell, and you'll use g++ (the program you call to use c++ with gcc) to compile your programs. You'll probably want to read up on the bash shell and unix commands in general.

Overall, I'd recommend using cygwin and ddd. Msys will limit your debugging opportunities, but cygwin has its own X server, which will let you use ddd, which will make your life much easier. Unix is really set up for use without an IDE, and will make your life simpler once you learn how it works.

posted by devilsbrigade at 5:09 PM on July 12, 2007

Wow. Lots of people posted while I was writing that. Ubuntu will make your life easier for developing without an ide, if you can live with ubuntu.
posted by devilsbrigade at 5:10 PM on July 12, 2007 [1 favorite]

In that case I think Java + Eclipse would be most instructive. It's multiplatform, well-documented, and Java IDEs are more powerful than those for other mainstream languages. Ultimately, though, a developer's environment is pretty much a religious issue, so I doubt you'll get consensus.

I'm not trying to convince you that IDEs are great, by the way. I'm pretty ambivalent about them myself. Their refactoring abilities are unquestionably awesome since they make it super easy to make sucky code suck less, which makes it more likely that the programmer will take the time. But I've interviewed lots of people who can't program without their IDE at all. So they're like any tool -- only as good as the person using them. Personally I've only found an IDE to be a productivity gain when I'm working in Java, but it's totally likely you'll have a different experience.
posted by amery at 5:19 PM on July 12, 2007

my command line isn't working

Your PATH environment variable isn't set right. It's probably empty. Your path needs to point to a series of directories to find the programs to run.
posted by DarkForest at 5:21 PM on July 12, 2007

Curse you, preview. Yes, absolutely. Barebones C/C++ development will be easier on any Linux distro than it will on Windows. I'd also give a shout out to Valgrind if you care about looking for memory leaks or threading bugs.
posted by amery at 5:22 PM on July 12, 2007

So to do barebones c++, working with linux (Ubuntu) would be much easier to do?

Yes. gcc is either already installed or is a one line install in Ubuntu. Installing cygwin takes a lot more effort and sometimes you just end up in a mess of path and environment problems.
posted by Gary at 5:34 PM on July 12, 2007

"I'm not really sure why a development environment or platform is needed."

Because compiling code from the command line, especially in Windows, is painful and prone to mistakes. Because you want syntax highlighting, a debugger, auto formatting features like indentation recognition, package and tag support, and maybe some more exotic features like built in API documentation or macro recording that just make your life a whole lot easier. You want it all in one package so you don't have to switch between the command line and your 5 active editor windows and a file browser and whatever else.

By all means, learning from the ground up at the command line is important, and there is a reason that any decent programming class you take will have you starting at the command line, but you will discover very quickly that there are good reasons most people don't do it this way.

A good compromise in Windows between the command line/notepad and an IDE behemoth like Visual Studio or Eclipse is Textpad.
posted by sophist at 6:38 PM on July 12, 2007

Or use Emacs for Windows instead of Notepad.
posted by zaphod at 7:15 PM on July 12, 2007

You might want to take a look at Bruce Eckel's Thinking in C++ which besides being a great free book is also a collection of instructions on how to set up some basic command line toolchains for C++ dev work.
posted by mmascolino at 7:37 PM on July 12, 2007

If you're interested in learning how to work effectively in a command line environment, I strongly recommend you install Ubuntu and learn to work in that one.

The Windows command interpreter can be persuaded to do many of the things that a respectable shell like bash can do with less fuss, but when you get past the desire to bend Windows to your will for the sake of the exercise, and want to get actual work done in an environment that's been built from the ground up for that purpose, unix+bash beats Windows+cmd all hollow.

You can make a lot of Unix stuff (including bash) run OK on Windows using Cygwin, but what you miss is the Unix culture - the standard places to install things, the standard ways that things talk to each other, the sheer variety of glues, and the lack of arbitrary limits.

To a large extent, IDE's are a reaction to the relatively impoverished support for actual programming in the Windows environment. An IDE attempts to be your complete one-stop shop for everything programming-related; it attempts to encapsulate decades of Unix culture in a single Windows app. IDE's are great until you need to do something they don't support - then they're awful.

You'll get a much, much better idea of what your IDE of choice is doing for you if you get some experience working in a Unix command line environment; and of those, Ubuntu GNU/Linux is the easiest to install, configure and come to grips with.

If you're determined to don the hair shirt and embrace the self-flagellatory attitude you'll need to get programming done on Windows without an IDE, at least pick a decent source code editor. Notepad is truly horrible for writing code in. Scite is nice, and works the same on Windows or Linux.

Vi is the fixie of Unix text editors (with ed and ex for wheels); Vim is the moped; and Emacs is the Harley-Davidson.
posted by flabdablet at 8:17 PM on July 12, 2007 [1 favorite]

As a very novice programmer, I've used DJGPP (gnu C/C++ compiler for windows) plus EditPlus (which has syntax highlighting for C++). I have no idea how standards-compliant or efficient DJGPP is, but it might be what you're looking for.

I don't remember having too much trouble setting it up and compiling/linking.
posted by blisterpack at 9:17 PM on July 12, 2007

MinGW provides a cl interface to gnu tools without much of the messy overhead of cygwin. Dev-C++ wraps an IDE around it if you do decide to go that route. Then, if you decide to go with linux, your code (the non-Win32-specific part of it anyway) will be easy to port over.
posted by nimmpau at 9:25 PM on July 12, 2007

I'll give a non-IDE response. Learn the basic commands that a makefile would do for you. Like how do you compile a bunch of files into object files? Then, what's the general form of the command to link all those object files into a single executable?

The make program already knows how to convert a .cpp file into a .o and .exe (for windows) file, but once you learn the basic commands to compile and link, then it will be instructive to create your own makefile.

I recommend cygwin over the windows command line. Remember that C was pretty much made to build unix, and so any unix shell is just going to be a much better fit than windows.
posted by philomathoholic at 10:49 PM on July 12, 2007

While it is commendable to want to understand all the different parts outside of an IDE please use a proper text editor. Knowing your text editor is as much a part of being a decent programmer as knowing your compiler/linker/debugger etc. As mentioned above Vim or Emacs is a good way to go. You will find using a linux or unix environment a major plus as well - C/C++ programmers playground.
posted by zemblamatic at 1:35 AM on July 13, 2007

flabdablet, I'd cast vim more as the Ducati than the moped, but otherwise a great comparison (though not only is Emacs the harley, its the truck used to tow the harley, plus every tool you could ever need to fix it should anything go wrong).

DJGPP is nowhere near standards complaint and is very far out of date. It's a compiler for DOS, so I don't know if it'll even run on modern Windows systems. MinGW / MSYS / Cygwin are basically the options for gcc on Windows.

For what its worth, I'd stay away from vim or emacs starting out. Both of them are great editors, and good to learn at some point, but if you put them on top of other stuff I seriously doubt you'll be able to plough through it all. Scite is a great recommendation. Its very straight forward to learn and use, and behaves relatively like you'd expect.

By the way, if you really get into unix programming, there's a great book called Advanced Programming in the UNIX Environment by Stevens. Stevens is one of those classic authors that knows what he's talking about from the real ground up, and its a great book (his series on TCP/IP is excellent as well).
posted by devilsbrigade at 4:58 AM on July 13, 2007

Install Linux, BSD, or some other free version of UNIX on an old computer, or a partition of your current computer. It will have all the devlopment tools you need to start programming in C++: gcc, and vim or emacs. You write a program in your favorite text editor, and compile it with g++. If you write complicated programs, you'll may want to look into how Makefiles work.

Learning C++ under XP is going to suck.
posted by chunking express at 7:00 AM on July 13, 2007

If you have access to os x, you have gcc (g++) if you download the developer's kit from apple. (free) You can edit code in vi and do it all by command-line.

Also, my webhost provides ssh access to their linux boxes and has all you need to compile c++. ($5/month)
posted by kamelhoecker at 7:35 AM on July 13, 2007

Lots of good advice has been given here. Here's more :)

(I have to leave ASAP so you'll have to Google for links, sorry)

MS Visual C++ Express is really not bad. If you will be primarily programming apps for use on Windows, it's a good way to go.

I've also had success installing and using Dev C++ on Win XP. It provides IDE-ish support, but you can also tweak things, or use the command-line when you want.

Life is too short for Notepad. Get at least a decent text editor. I like Ultraedit alot.

There's a new free coders' editor from ActiveState called Komodo, too.

Finally, a good starting book helps. I used C++ Programming: Visual QuickStart Guide. It assumes you know nothing, but guides you through all the steps of installing and configuring the tools, and it has working samples of all the basic interface techniques. Great training wheels.
posted by Artful Codger at 11:22 AM on July 13, 2007

On the subject of editors, PsPad is free (TextPad costs $16.50) and doesn't suck for editing C++ source code. It has a C++ "explorer" as well which you can use for browsing through your classes' objects.
posted by ostranenie at 7:11 AM on July 18, 2007

« Older Routed by my slow router   |   Get on Camouflage Newer »
This thread is closed to new comments.