473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Vector and SWIG java problem

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{
myV[i].get_length();
etc...
}

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
System.out.println("Size:"+newV.size());
...Results
Size:0

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,
Jaz
Jun 8 '07 #1
0 1628

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

Similar topics

0
by: Andrew Collier | last post by:
hello, i am not sure whether this problem relates to swig, python or my c++ compiler. +please forgive me if this is inappropriately posted but i am sure that someone +on this list must have some...
0
by: Bo Peng | last post by:
Dear List, I have had success in using vector.i of SWIG to map between c++: foo(vector<int>) python: foo() However, the map of vector of objects fails: c++: foo(vector<obj> )
1
by: Java and Swing | last post by:
I am trying to wrap some C code I have. Currently I have something like... defs.h ----------- typedef unsigned long MY_DIGIT; myapp.c ------------- void MakeDigits(MY_DIGIT digits) {
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
13
by: smp | last post by:
Does anyone know why making a vector of pointers is so much less efficient than a vector of objects? For a simple example: int num = 20; vector<int*v_int_ptr; v_int_ptr.reserve(num); ...
4
by: Jazi | last post by:
Hello All, I have a function in C++ that takes an array of struct. I want to convert this function to java using SWIG. Here what I have structs.h typedef struct myStruct{ char name;
0
by: doobybug | last post by:
Hi all, I really need your help! I am new to java and have some problems with my code. I have a program which inputs questionnaires and creates an object for each questionnaire. These objects are...
1
by: Sells, Fred | last post by:
I'm using python 2.4 under linux (centos 5.1). I need to pass an array of doubles to a c function but am getting an error, shown near the bottom of this post....
0
by: Thomas | last post by:
Hi, I have a C++-Class "compiled" with SWIG into a Python-Modul. It works fine. But there's is a problem with the C++-Returntype vector<string>. If I call in my compiled Python-Module a certain...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.