Demo-2 <<-BACK            HOME          NEXT-->>  Demo-4
side4linux, a simple integrated development environment!

CLC Demo-3 Link to an external dynamic library.


Step-1 Create a function called 'printSin()'.
  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 'trydynamiclib' 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 'Trydynamiclib', this opens the 'Trydynamiclib' project folder.
  13. Double click on 'trydynamiclib.prf', this opens the 'Trydynamiclib' 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. )
  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,

#define DegreeToRadian 57.295779506

#include <stdio.h>
#include <stdarg.h>
#include <math.h>                 // this is added so that we can link to the external maths library ''

int main(int argc, char *argv[])
{ // calculating the trig. sine of the angle 45 degrees
  double answer = 0.0, radianAngle = 0.0;

  radianAngle = 45/DegreeToRadian;   // need radians because this is what the sin() function expects.
  answer = sin(radianAngle);
  printf("\nThe Trig. Sine of 45 degrees is %4.4lf\n\n ",answer);

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/PRODUCTS/MC1/CLC/Testdynamic for your reference in case of trouble )
Note: Notice that files and filenames mentioned here are 'case sensitive' !!!!!     

Steps-2/3/4 Result of building and running the program,
db@wks1:~/Data/Projects/SIDE/DEMOS/SIDEdemos/CLC/Trydynamic/src$ ./trydynamic

The Trig. Sine of 45 degrees is 0.7071


Step-5 Removing the 'libm' library from the Project,
main.o: In function `main':
/home/db/Data/Projects/SIDE/DEMOS/SIDEdemos/CLC/Trydynamic/src/main.c:33: undefined reference to `sin'
collect2: ld returned 1 exit status
make[3]: *** [trydynamic] Error 1

Step-6 Running the 'ldd' Program
db@wks1:~/Data/Projects/SIDE/DEMOS/SIDEdemos/CLC/Trydynamic/src$ ldd ./trydynamic =>  (0xffffe000) => /lib/tls/i686/cmov/ (0xb7f63000) => /lib/tls/i686/cmov/ (0xb7e19000)
        /lib/ (0xb7f9a000)

Completion of Demo-3,

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