My goal is to use the C libraries to form web apps.
I have chosen the way to do that via using "SWIG" tool. The Swig tool requires three things:
.c
file which defines all the functions..i
file also called interface file which is creating the interface to load the APIs wherein I used theextern
keyword.APP written in Javascript extension (
.js
file).
I used SWIG tool to compile and run this app to verify the .js
file has made correctly.
The application is running fine on XMING X11 window.
On compilation it creates _wrap.o
, .o
file and libFILENAME.so
.
Now I want to run this app on browser page.
For this I have used the webkit clutter port which gives us the MxLauncher code.
I'm using webkit_iweb_view_load_uri(WEBKIT_IWEB_VIEW(view), "filename.html");
API to load my html file to run that Javascript on my webpage view.
I'm linking the .so
created at the compilation time.
Error Message: JS CONSOLE: file:///filename.js: ReferenceError: Can't find variable: example
filename.c
int gcd(int x, int y) `enter code here`{
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}
filename.i
%module example
extern int gcd(int x, int y);
filename.js
x = 42;
y = 105;
g = example.gcd(x,y);
How to get my goal to be achieved?