[PyQt] Compiler Error using SIP: error C3861: 'PyUnicode_FromFormat': identifier not found

Jamie Riotto jamie.riotto at gmail.com
Sun Oct 25 21:45:44 GMT 2009

I'm trying to learn to use SIP, and I've started out with a simple
Vector class. The sip file looks like this:

%Module Vec3 0

class Vec3 {

#include "Vec3.h"


	float x;
	float y;
	float z;	

	Vec3(float xpos,float ypos,float zpos);
	float getX();
	float getY();
	float getZ();
	SIP_PYOBJECT __repr__() const;
	sipRes = PyUnicode_FromFormat("Vec3(%f, %f, %f)", sipCpp->getX(),
sipCpp->getY(), sipCpp->getZ());


The __repr__ section is my frist attempt at implementing python
functions (operators next). I've used QPoint.h and QPoint.sip
as my starting point. The c++ code compiles ok , but when I try to
compile SIP with the following makefile,

I get the following error:

vec3.sip(26): error C3861: 'PyUnicode_FromFormat': identifier not found

Any suggestions? Thanks - jamie

TARGET = vec3.pyd
OFILES = sipvec3cmodule.obj sipvec3Vec3.obj
HFILES = sipAPImesh.h

CC = cl
CXX = cl
LINK = link
-Ic:\python25\include -Ic:\python25\sip
CFLAGS = -nologo -Zm200 -Zc:wchar_t- -O2 -MD -W3
CXXFLAGS = -nologo -Zm200 -Zc:wchar_t- -O2 -MD -W3 -w34100 -w34189
name='Microsoft.Windows.Common-Controls' version=''
publicKeyToken='6595b64144ccf1df' language='*'
processorArchitecture='*'" /INCREMENTAL:NO
LIBS = /LIBPATH:c:\python25\libs ..\lib\vec3.lib c:\python25\site_packages
.SUFFIXES: .c .cpp .cc .cxx .C

	$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<

	$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<

	$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<

	$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<

	$(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo @<<

all: $(TARGET)


	  $(OFILES) $(LIBS)
	mt -nologo -manifest $(TARGET).manifest -outputresource:$(TARGET);2

install: $(TARGET)
	@if not exist c:\python25\Lib\site-packages mkdir c:\python25\Lib\site-packages
	copy /y $(TARGET) c:\python25\Lib\site-packages\$(TARGET)

	-del $(TARGET)
	-del sipveccmodule.obj
	-del sipvecVec3.obj
	-del $(TARGET).manifest


More information about the PyQt mailing list