By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

Vector and SWIG java problem

P: 21
I would appreciate if someone can help me dealing with wrapping java around c++ using SWIG. I have wrapped simple classes without any problem but I had some difficulties getting a vector function working. Here is what I have. I have two classes in C++; Fold class and Subs class. In the Subs class there is a method called get_all_folds that returns a vector of Fold objects. I compiled my c++ code and wrote a c++ driver and everything works just fine.
and here what I had in my c++ driver:

subs mySubs=new subs();
vector<Fold> myV=mySubs.get_all_folds("by name");
for everyitem in myV{

Now I used the SWIG to wrap java around it. Everything compiles fine except when I tried to read out the objects of this function. I noticed that there is no vector returned even though there was no error compiling or even running. It just will not return anything. Here is what I have in my java driver.

System.loadLibrary("mylib");/c++ library
subs newSubs=new subs(); //my subs class
SWIGTYPE_Fold_vector newV=newSubs.get_all_folds("by name");//SWIGType is the vector of Fold objects built by SWIG

I have tried other approaches but I would get errors. Can someone help me or see what I am doing wrong? If you have suggestions on how you will go about doing it please let me know.

I appreciate your help,
Jun 8 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.