Demo-3 <<-BACK            HOME          NEXT-->>  Demo-5
side4linux, a simple integrated development environment!

CLC Demo-4 Allow the entry of 'include' search directories in CLC command line 'C' projects.


Step-1 Call a 'glib' function called 'g_print()'.
  1. Open 'side4linux' and click on 'Project>New Project' in the Main Menu.
  2. Select 'Command Line 'C' Program' and click on 'NEXT' in the 'Select New Project Type' Dialog Box.
  3. Select the 'PRODUCTS' Product Area in the Product Selection Dialog and click on 'OK',
  4. Select 'MC-1' from the Product Area selection Combo Box and click on the 'Next' button,
  5. In the New Project dialog enter the name of 'includes' and click on 'Build'.
  6. Once the Project is 'Built', close and then re-open it to let things settle into place.
  7. 'Project>Close Project'
  8. 'Project>Open Project'
  9. Double click on the 'PRODUCTS' Product Area,
  10. Double click on the 'MC1' Product,
  11. In the file dialog double click the  'CLC' folder, this takes you to where command line 'C' language projects are kept.
  12. Double click on 'Includes', this opens the 'Includes' project folder.
  13. Double click on 'includes.prf', this opens the 'Includes' project file.
  14. Left click the tabs on the left hand side of the 'Notebook' and notice the file tree results, this is the 'Project File Tree Explorer'
    1. Visual  ( nothing here )
    2. Files    ( main )
    3. D-Libs ( m ) = maths  '' dynamic library added automatically by the new project process.
    4. I-Libs  ( Internal Static libraries, but nothing here, yet. )
    5. INCLUDES   ( nothing here )
  15. Click on the 'TXT' Toolbutton and open 'main.c' and edit it to be the same as follows, then click on the 'Build' Toolbutton,

#include <stdio.h>
#include <stdarg.h>
#include <glib.h>                 // this is added so that we can link to the external dynamic library 'glib-2.0' to use it's 'g_print()' function.

int main(int argc, char *argv[])
{ // output 'Hello World' using the 'g_print()' function

  g_print("\nHello World!\n);  // modified existing 'printf()' function.

Hint: Make sure that there is a blank line above and below your source code in case the compiler you are using complains!
         ( a completed copy of this project is stored in -/SIDE/DEMOS/CLC/Includes for your reference in case of trouble )
Note: Notice that files and filenames mentioned here are 'case sensitive' !!!!!     

Step-2 Add in the dynamic library to link to ( glib )

HINT: In this and the next step just copy and paste the entries instead of trying to do it manually to prevent errors!

Step-3 Add in the 'Include' search path for ( glib )

Step-4 Result of building and running the program,
On building the program notice in the 'Output Window' the lines

  libtool: link: gcc -Wall -g -g -O2 -o includes main.o  /usr/lib/ -lm

It shows that we are linking to the 'glib' dynamic library at runtime.
On running the program we get the following or something similar ( don't forget the './' dot forward slash before the program name. ),

db@wks1:~/Data/Projects/SIDE/DEMOS/SIDEdemos/CLC/Includes/src$ ./includes

Hello World!

Step-5 Running the 'ldd' Program

 Trying to determine which libraries are dynamically linked to 'includes'. The result is,
db@wks1:~/Data/Projects/SIDE/DEMOS/SIDEdemos/CLC/Includes/src$ ldd ./includes =>  (0xb8067000) => /usr/lib/ (0xb7f96000) => /lib/tls/i686/cmov/ (0xb7f70000) => /lib/tls/i686/cmov/ (0xb7e0c000) => /lib/ (0xb7dda000)
    /lib/ (0xb8068000)

The result shows that we are dynamically linking to,

Completion of Demo-3,
NOTE: If you strike trouble then look in ~~/SIDE/DEMOS/SIDEdemos/CLC/Includes

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