[PyKDE] Re: How can I use SIP to wrap STL class?

ejoy ejoy at peoplemail.com.cn
Sat Apr 13 15:14:12 BST 2002


On Wednesday 10 April 2002 17:29, you wrote:
> If you can't modify the C++ code to return a Python list, you will
> need to write %MemberCode (following foo's declaration in the .sip
> file) to accomplish that (I'm sure Phil will correct me if I'm
> wrong). "ListType" can be any name you choose. "sipCpp" and
> "sipCppPtr" in the PyQt/PyKDE2 examples are the pointers that
> represent the data to and from C++ respectively - use those names.
Thanks Jim for his kindly reply.I've created a vecstring.sip from qstrlist.sip
and a a.sip to wrap:
#include <vector>
#include <string>
using namespace std;
class A {
public: 
	A();
	~A();
    void foo(const vector<string>&,vector<string>&);
};

The a.sip looks like:
%Module A
%Include vecstring.sip

%HeaderCode
#include "a.h"
%End

class A{
public:
void foo(const VecString&,VecString&);
};

and the vecstring.sip is in attachment.

The compile progress is ok with the following output:

/usr/local/bin/sip -s ".cpp" -c sip a.sip
cd sip && make
make[1]: Entering directory `/home/zl/prj/py/py/sip'
g++  -c -I.. -I. -I/usr/include/python2.1 -I/usr/local/include/sip  
Acmodule.cpp
g++  -c -I.. -I. -I/usr/include/python2.1 -I/usr/local/include/sip  sipAA.cpp
g++ -shared -L/usr/local/lib/ -lsip -o libAcmodule.so *.o
make[1]: Leaving directory `/home/zl/prj/py/py/sip'

When I try to import A from python interpreter a error occurs:

>>> import A
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in ?
    import A
  File "/home/zl/prj/py/py/sip2/A.py", line 5, in ?
    import libAc
ImportError: /home/zl/prj/py/py/sip2/libAcmodule.so: undefined symbol: 
sipConvertTo_VecString__FP7_objectPPt6vector2Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0Zt9allocator1Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0Pi
>>> import A

Seems like a linking problem but I'm not sure.
Can you tell me where is the problem?
-- 
					Sincerely yours,
						ejoy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vecstring.sip
Type: text/x-c++
Size: 1398 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020413/2ab8c5fc/vecstring.bin


More information about the PyQt mailing list