HOME            UP --^           NEXT-->>  Demo-2
side4linux, a simple integrated development environment!

CLC Demo-1     Load, Compile and Run the 'Sample' project.


Purpose:  To provide a basic introduction to command line 'C' language programming and to run the binary code in a Terminal. The sample program will output the text 'Hello World!'.

Requirements: Make sure that the 'C' compiler is installed correctly, if not then read 'setup C build environment.txt'

  1. Open 'side4linux' and click on Project>Open Project in the Main Menue.
  2. Double click on the 'DEMOS' Product Area,
  3. Double click on the 'SIDEdemos' Product,
  4. In the file dialog double click the  'CLC' folder, this takes you to where 'C' command line projects are kept.
  5. Double click on 'Sample', this opens the 'Sample' project folder.
  6. Notice that project names are set to be an upper case letter followed by lower case letters (easier on the IDE's Project management routines).
  7. Double click on 'sample.prf', this opens the 'Sample' project file.
  8. Notice that the left bottom status bar window says 'Project: Sample' which is the Project Name
  9. Notice that the next window says 'Ptype: CLC' which is the Project Type.
  10. Try clicking on 'Project' on the Main Menue, you will notice that 'Close Project' is now active.
  11. Click on the 'Open' toolbar button, observe the two files 'Main.c', 'Main.h'
  12. and double click on 'Main.c'.
  13. Notice that the 'Save' and 'Save All' buttons are now active.
  14. Notice the highlighted file text in the tabbed file 'Notebook'.
  15. Click on the 'Open' toolbar button again and open the  'Main.h' file also.
  16. Notice that by clicking on the 'tabs' you can change from one file to another.
  17. Keep in mind that these are only copies of the files on disk, if you make changes then you must 'Save' them.
  18. Now click on the 'Build" toolbar button and you should see something like this in the following screenshot,
Screenshot-1

From the screenshot above you can see that the 'Output window' has the output from the 'C' compiler and the
'Status bar' says 'Build Success' !

Now let us run the compiled binary by opening a terminal in the 'src' directory as follows,

Using 'Nautilus' change to the --SIDE/CLC/Sample/src directory

Screenshot-2

Notice that the left hand file explorer pane has been set to 'Information'.
Notice the 'Open with Terminal' box inside this pane.
(If you have not got this box yet then left click on a folder and set to open with 'Terminal' then close and reopen Nautilus.)

Now click on
the 'Open with Terminal' box which will open a terminal, then type './sample' and press the 'Enter' key.
This should result in the following text to appear on the terminal window (or something similar containing the line '
Hello World!',

db@wks1:~/Data/Projects/SIDE/CLC/Sample/src$ ./sample

Hello World!
db@wks1:~/Data/Projects/SIDE/CLC/Sample/src$


Which should like something like this in the Terminal window,

Screenshot-3

The './' at the start of the program name means 'to launch the copy of the program in the current folder', this is not as useful as one might think as other users who do not have access to your user space cannot run your new program. To overcome this and make the program available to others we need to put the new program into the machine's execution path. Try typing in the following into the Terminal you have opened,

echo $PATH

this should provide a display of what is in your current execution path ( 'echo PATH' would just print 'PATH' so make sure you prefix the environment variable with the contents '$' qualifier!)

So now we will make the program global, change to the superuser 'root' by issuing the 'su' (select user) command, if you have forgotten how then re-read,

'setup C build environment.txt'

Now issue the command 'make install' to transfer the new program to /usr/local/bin then type 'exit' and press the 'Enter' key to return to your user space.

Try now issuing the command 'sample' without the dot and forward slash, if it worked then everyone can now use your program!

Now close the Terminal window and return to the IDE.
Click on Project>Close Project from the Main Menue and now close down the IDE by clicking the 'X' in the top right corner.

Screenshot-4If you are new to programming in 'C' then we suggest you could purchase the
book 'C Programming in easy steps' by Mike McGrath puplished by
'Computer Step' ( ineasysteps.com ) ISBN 1-84078-203-X.














We will provide other demos as 'side4linux' develops to cover 'C' programming and integration into a real world machine controller.