[PyKDE] Simple sip program

Greg Green gregory.p.green at boeing.com
Thu Jan 25 22:47:16 GMT 2001


I was trying out a simple sip program before progressing to bigger and
better things. However I can't seem to make it work. Here is the sip
file:
-----------------------------------------------------------------------------------------------------
%Module hello

class world
{
%HeaderCode
#include "hello.h"
%End
	world();
	~world();
	const char* get() const;
};

const char* sayit();
-----------------------------------------------------------------------------------------------------

And here is the C++ implementation:
-----------------------------------------------------------------------------------------------------

class world
{
public:
	world() {}
	
	~world() {}
	const char* get() const { return "hi"; }
};

const char* sayit()
{
	return "sayit";
}

-----------------------------------------------------------------------------------------------------
The module compiles fine but I get an error when I try to create a class
instance of world:

ufo:/home/ggreen/code/bpl > python
Python 2.0 (#8, Jan 24 2001, 13:10:20) [C] on irix646-n32
Type "copyright", "credits" or "license" for more information.
>>> import hello
>>> h = hello.world()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "hello.py", line 11, in __init__
    libhelloc.sipCallCtor(0,self,args)
TypeError: Invalid argument types to world()
>>>

BTW, PyQt works fine so I don't think it is a build problem. I also
attached my Makefile.

Thanks
-- 

Greg Green
Advanced Design Systems
Math & Computing Technology
Boeing
(425) 865-2790
-------------- next part --------------
topdir = /proj/seanc/python/python-2.0-irix-6.5-n32

CXX = CC
CXXFLAGS = -n32 -I. -I$(topdir)/include/sip -I$(topdir)/include/python2.0
LDFLAGS = -n32 -shared -L$(topdir)/lib -lsip

all: libhellocmodule.so

sip_helper: sip_helper.cpp
	$(CXX) $(CXXFLAGS) sip_helper.cpp -o sip_helper

siphelloVersion.h: sip_helper
	./sip_helper >siphelloVersion.h

hello.o: hello.cpp hello.h
	$(CXX) $(CXXFLAGS) -c hello.cpp

hellocmodule.cpp siphelloworld.cpp siphelloworld.h: hello.sip
	sip -c . hello.sip

hellocmodule.o: hellocmodule.cpp siphelloVersion.h
	$(CXX) $(CXXFLAGS) -c hellocmodule.cpp

siphelloworld.o: siphelloworld.cpp
	$(CXX) $(CXXFLAGS) -c siphelloworld.cpp

libhellocmodule.so: hellocmodule.o siphelloworld.o hello.o
	$(CXX) $(LDFLAGS) hellocmodule.o siphelloworld.o hello.o -o libhellocmodule.so



More information about the PyQt mailing list