• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swig

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

do anybody know how to use swig??
if anybody is aware of it, kindly tell the procedure and the working example.....

i tried with the available swig examples to create JNI wrappers etc., but it is throwing some errors...

please..

thanks in advance.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://faq.javaranch.com/java/TellTheDetails
"Throwing some errors" is really not helpful.
 
bharani rao
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Rob,

I posted that in a haste. actually this is dragging since 1 month.. some kind of uneasiness in me.

ok fine then,

i'm using Linux. I have to create a interface for a softphone project( done in c++) in java using JNI and swings.

i tried for month and couldn't get it right.
last thursday we e-mailed to one guy who said he has done softphone interface in JAVA using JNI(just as our requirements)

he replied, in his coding he used SWIG to generate all the wrapper classes. so we moved on to SWIG.
we are just running the sample program available in google. once we succesfully run this we plan to move to our main cpp program to create wrapper classes with SWIG.

so, we downloaded the.tar SWIG file and extracted.

now,
my c program is



my interface program is,




then i give the command

swig -java example.i

it runs and generates the files,

example.java
exampleJNI.java
example_wrap.c

the I compile the example.c and example_wrap.c files with the command

gcc -c example.c example_wrap.c -I/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/include -I/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/include/linux

it shows the errors,


th e example_wrap.c file it generated is,






kindly advise....

thanks in advance







 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My_variable is not declared in that C file, nor is it in any of the included files. To be honest, it surprises me that the compiler doesn't complain about the fact, my_mod and get_time functions.

If possible, change your initial C program to this:
(looks a lot like your example.i, doesn't it )
You should then include this new header file in your example_wrap.c:
 
bharani rao
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you rob..


let me check..
 
bharani rao
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rob,

i found that the error which i got earlier disappeared when i use the coding from the following link.

http://www.swig.org/tutorial.html

now i made the changes you recommended.

it is saying "example.h" : no such file or directory in both the example.c file and the example_wrap.c file.
so i removed that.

now i created the .so file and placed that in /usr/lib folder. this is to be done because the .so file is read from that path....


now i created a java main file (main.java) as in the above link. i compiled it too with out errors.. but when running it is showing the error in My_variable..

  • Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.My_variable_get()D
    at exampleJNI.My_variable_get(Native Method)
    at example.getMy_variable(example.java:16)
    at main.main(main.java:4)


  • what that signifies..

    i'm just suing that sample program...

    advise please


    thanks in advance


     
    reply
      Bookmark Topic Watch Topic
    • New Topic