Skip to main content »

Trinity College Dublin

  • Note 1: Some links
  • Note 2: Installing a c++ compiler. Please send me any additional links and tip you might have about this.
    • Ubuntu: the package build-essential will install g++, either find it in Synaptics or type sudo apt-get install build-essential in a terminal.
    • Fedora: type su to become root and then yum install gcc will do it, otherwise open Add/Remove Software, search for gcc and select "Various compilers".
    • Windows: installing g++ requires that you first install cygwin, a linux compatibility layer: look here for instructions, I have no way to test them, so let me know if they work or otherwise. There is an alternative set of instructions here.
    • Windows: bloodshed.net has a free c++ compiler, Dev-C++ based on g++. This is an IDE, an integrated developer environment, so it will include an editor specially set up to write c++ code, a debugger, a special window to compile the programme and so on.
    • Mac: You need to install something called xcode, again I can't test this so let me know.
  • Note 3 There are lots of different editors you can use to write and work on programmes; there are IDEs which are specially designed for different programming situations, or general editors like notepad and gedit. The two most powerful editors are emacs and vi: neither are particularly easy to use at first because using them efficiently requires that you get the hang of various abbreviations in vi or key-strokes in emacs, but they are both allow you to work extremely efficiently when you get used to them. There is a lot of passionate discussion about which is best, people who like one don't understand why you would like the other. This is known as the Editor War. Of course, they are both probably equally good and people simply prefer the one they are used to, however, only idiots prefer vi.
    • To edit a file called foo.cpp type emacs foo.cpp; if that file doesn't exist in the current directory, it is created. The save a file type ^x ^s, where the ^ means hold down the control key. To save with a different name type ^x ^w, to quit type ^x ^f.
    • Emacs remembers two points in your file: the point, where the cursor is, and the mark. A nice explanation is at emacsworld.blogspot.com. Press ^space, control space bar, to designate the current point as a mark, now, ^x ^w cuts between the mark and the point, ^x M-w copies between the mark and the point, where M-w means press w while holding down the alt key. When something is copied or cut it is place in a store called the kill ring, ^y, called yank, pastes in the top item from the kill ring, pressing M-y immediately afterwards will substitute the next item, pressing it again, the item before that and so on so you can paste anything that has been previously copied or cut. ^k, called kill deletes from the point to the end of the line and saves it to the kill ring.
    • To split the screen in two windows ^x ^2, got back to one window using the current window, ^x ^1 when there are more than one windows ^x ^0 gets rid of the current window. ^x ^o moves between windows.
    • You can load a file with ^x ^f, emacs refers to open files as buffers; ^x ^b changes the buffer being displayed in the current window; different windows can show different buffers, ^x b opens a new window showing a list of buffers. Note that ^x ^s only saves the buffer in the active window, to save all buffers use ^x s
    • ^g cancels a command, useful is you get stuck in the little window in the bottom that is used for typing commands to emacs, basically not all commands are associated with key-strokes; less used commands are typed in directly by first going to the little window at the bottom using M-x. It can be very confusing to end up there by accident, but pressing ^g a few times will sort it out.
    • There are lots of emacs tutorials, here is one: uchicago.edu
    • Here is a list of short list of commands
    • Here is the home page www.gnu.org