Scilab/C4/Developing-Scilab-Toolbox-for-calling-external-C-libraries/English
Developing Scilab Toolbox for calling external C libraries
Author: Rupak Rokade
Keywords: scilab, C, external libraries, interfacing, toolbox
|
|
Show Slide:
Opening Slide |
Welcome to the spoken tutorial on “Developing Scilab Toolbox for calling external C libraries” |
Show Slide:
Learning Objectives |
In this tutorial, we will learn to-
|
Show Slide:
Systems Requirements |
To record this tutorial, I am using-
|
Show Slide:
Pre-requisites |
To practice this tutorial, you should know-
If not, watch the prerequisite Scilab and C tutorials on this website. |
Show Slide | This tutorial makes use of files given in the Code files link on this tutorial page.
These include
Download these before continuing. |
Show Slide |
|
Show Slide |
|
Show Slide |
|
Show Slide |
Let us see how this external library is generated. |
Switch to the Downloads folder | Switch to the folder where you have downloaded the external-library.zip file. |
Right-click on the zip file >> Extract here option | Right-click on the zip file and choose Extract here to extract its contents. |
Right-click on external-library directory >> So this option isn't available on my OSI prefered new window to show two things at onceOpen in new tabOpen in new window. | Open the external-library directory in a new window.
To do so, right-click on the external-library directory. Choose the option Open in new window. |
gedit mul.c | Locate the mul.c file.
And double click on it to open it in a text editor. |
Point to mul function definition.
|
You can see it contains a function definition.
The name of this function is mul. Close this file. |
Right-click inside external-library directory >> click on Open in Terminal. | We will build a shared object file out of the mul.c file.
Right-click somewhere inside the external-library directory and click on Open in Terminal. |
Press Ctrl+Alt+T keys
Change directory to external-library |
If you don’t get this option, open the terminal by pressing Ctrl+Alt+T keys together.
However, you will have to manually change the current directory to external-library directory. |
Type ./run.sh >> press Enter | Now type dot slash run dot sh and press Enter.
Ignore the warnings about it cannot remove certain files. However, pay attention to any compilation failure related messages. Now, type ls and press Enter. You can see a file with name libmul dot so This is our compiled external library that we will be using in our Scilab toolbox. |
Show slide |
This thirdparty directory is now ready to be used in the test_toolbox
|
Show slide |
|
Show Slide |
|
Switch to external-library directory >> Right-click on thirdparty directory >> click on Copy | Switch to the external-library directory.
|
folder >> Right-click on the zip file >> choose Extract here | Come back to the folder where the Scilab6-Test-Toolbox-master.zip code file is saved.
|
Open Scilab6-Test-Toolbox-master >> Right-click inside this folder >> click on Paste. | Open the folder Scilab6-Test-Toolbox-master.
|
This will paste the thirdparty directory inside the
Scilab6-Test-Toolbox-master directory. | |
Show Slide | Now let us learn more about the Scilab toolbox.
|
Show slide |
|
Scilab6-Test-Toolbox-master directory >> open sci_gateway | Now come back to the Scilab6-Test-Toolbox-master directory.
|
Open cpp | Open the folder cpp. |
Open sci_multiply.cpp | Now, open the file sci underscore multiply.cpp by double-clicking on it.
|
Point to mul.h header | It includes the mul dot h header file. |
Point to fname variable | The fname variable declares the name of this function.
|
Point to the code >> call to mul function | The file also has some code which is followed by a call to the mul function. |
This mul function is defined inside the dot so file that we generated earlier. | |
Put text on screen for this part | Note that you need to understand the Scilab C API in order to fully understand this code. |
Close this file. | Close this file. |
Open builder_gateway_cpp.sce | Locate the file builder underscore gateway underscore cpp dot sce.
Right-click on it and choose Open with text editor |
Point to variable Function_Names. | See the variable Function underscore Names.
|
Point to variable Files. | See the variable Files.
In our case it is sci underscore multiply.cpp |
Point to variable Linker_Flag. | Next see the variable Linker underscore Flag.
|
Close this file. | Close this file. |
Start Scilab >> Click on File menu >> Browse for new | Now, let’s start Scilab.
|
Browse to Scilab6-Test-Toolbox-master directory >> click on Ok button. | Browse to Scilab6-Test-Toolbox-master directory and click on the Ok button. |
Scilab console >> type exec builder.sce >> press Enter | On the Scilab console, type e x e c space builder dot sce and press Enter. |
Do as per narration | A pop up window will open.
|
This should build the toolbox without any difficulty.
| |
Type exec loader.sce >> press Enter | Then type e x e c space loader dot sce and press Enter.
|
Type help >> press Enter | Then type help and press Enter.
|
Point to left side >> open test_toolbox
|
On the left hand side, locate the test underscore toolbox and click on it to open it.
|
Click on link for multiply function >> scroll to Examples | Click on the link for multiply function.
|
Click on execute button | Click on the execute button on the top right corner of the Examples section.
|
Scilab console | Switch to the Scilab console. |
Point to multiply function | See that the multiply function has been called.
|
Put text on the screen for this part. | Now let us see how to write the help content for a function.
|
Scilab6-Test-Toolbox-master directory >> Open macros directory
|
Switch to the Scilab6-Test-Toolbox-master directory.
|
Right-click on multiply.sci >> Open With Text Editor | Right-click on the file multiply.sci and choose Open With Text Editor. |
Point to "multiply" function declaration
|
Notice that this file has a function declaration named multiply.
|
Show slide |
|
Show slide | A few tips.
|
Show slide |
|
Scilab6-Test-Toolbox-master directory >> Open it is not falling in the scope of this tutorialPlease explain about loader.sce file and also the remaining folders such as etc, jar, localesbuilder.sce | Switch to the Scilab6-Test-Toolbox-master directory.
|
Scroll to the end
|
Scroll to the end.
|
Show Slide:
Summary |
Let us summarise.
In this tutorial, we learnt to:
|
Show Slide:
Forum to answer questions |
Do you have questions in this Spoken Tutorial?
Choose the minute and second where you have the question. Explain your question briefly. Someone from the FOSSEE team will answer them. Please visit this site. |
Show Slide:
FOSSEE Forum |
For any general or technical questions on Scilab, visit the FOSSEE forum and post your question. |
Show Slide:
Circuit Simulation |
The FOSSEE team coordinates the Textbook Companion project.
We give Certificates and Honorarium to the contributors. For more details, please visit this site. |
Show Slide:
Lab Migration |
The FOSSEE team coordinates the Lab Migration project.
|
Show Slide:
Acknowledgment |
Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.
|
Thank you slide
|
This is Rupak Rokade from IIT Bombay signing off.
Thank you |