Developing C/C++ code at the command line: Part 1
Slickedit is the best one by far, but I'm gonna geek out and see if I can get a decent development environment going with vi or emacs or nano, and the GNU toolchain.
1)
Configuring Nano:
Luckily my Ubuntu distro comes with text highlighting files for various programming languages. So all I have to do is include the one for C/C++ in my .nanorc file. This file may not exist so just create it with:
eamoc@knut:~$ nano ~/.nanorc
Then just add a reference to the appropriate file. Edit .nanorc to include:
include /usr/share/nano/c.nanorc
Then add the following to allow multiple files open at once:
set multibuffer
Now you can switch between files on the buffer by doing "Alt >" or "Alt <"
2)
Install the compilers:
sudo apt-get install build-essential
3)
Install the debugger and documentation
sudo apt-get install gdb gdb-doc
The documentation can be viewed at:
file:///usr/share/doc/gdb-doc/html/gdb/index.html
Debugger internal documentation can be viewed at:
file:///usr/share/doc/gdb-doc/html/gdbint/index.html
4)
Install the GTK library for developing gui based programs
sudo apt-get install libgtk-3-dev
To make sure the C compiler (gcc) is installed, do a whereis, and a which if you like
eamoc@knut:~$ whereis cc
cc: /usr/bin/cc /usr/bin/X11/cc /usr/share/man/man1/cc.1.gz
eamoc@knut:~$ which cc
/usr/bin/cc
So to compile and run a simple c program,
Fire up nano and load a new file and paste in a simple helloworld example.
nano -wc helloworld.c
-w disables word wrapping
-c displays the cursor position
Compile:
cc helloworld.c
Then to run it, go:
./a.out
even better:
cc -o helloworld helloworld.c
Then you can do:
./helloworld
A future post will detail, the bare bones of a development environment which will include bash scripts that will generate project/make files and directories etc.