Q: Static extension of Python using SWIG

Helmut Zeisel helmut.zeisel at aon.at
Thu Jun 17 13:50:31 CEST 2004


I want to build a static extension of Python using SWIG and VC++ 6.0 as 
described in http://www.swig.org/Doc1.3/Python.html#n8 for gcc.

My file is testerl.i:

=========================
%module testerl

extern int hz(int i);

%include embed.i
==========================

I essentially use the same settings as described in
http://www.swig.org/Doc1.3/Python.html#n12 for dynamic extensions,
in particular I link python23.lib. (SWIG is 1.3.21, Python is 2.3.4).
Additionally I define the preprocessor macro STATIC_LINKED and the 
preprocessor inclide path Python-2.3.4\PC (for config.c). I tried to 
call swig with and without option c++.

Creating DLL works, but when linking for a statically linked version I 
get the warnings and error messages added below - any idea what is missing?

Did anyone succeed in building a statically extend python using VC? 
Which version?

Helmut

Linker error messages:
======================
testerl_wrap.cxx
D:\DATA\zeisel\vc\python\static\testerl\testerl_wrap.cxx(793) : warning 
C4273: 'Py_Main' : inconsistent dll linkage.  dllexport assumed.
D:\DATA\zeisel\vc\python\static\testerl\testerl_wrap.cxx(799) : warning 
C4273: 'PyImport_Inittab' : inconsistent dll linkage.  dllexport assumed.
Linking...
testerl_wrap.obj : error LNK2001: unresolved external symbol _initimp
testerl_wrap.obj : error LNK2001: unresolved external symbol _PyMarshal_Init
testerl_wrap.obj : error LNK2001: unresolved external symbol _initzipimport
testerl_wrap.obj : error LNK2001: unresolved external symbol _initxxsubtype
testerl_wrap.obj : error LNK2001: unresolved external symbol _inititertools
testerl_wrap.obj : error LNK2001: unresolved external symbol _init_random
testerl_wrap.obj : error LNK2001: unresolved external symbol _init_hotshot
testerl_wrap.obj : error LNK2001: unresolved external symbol _init_weakref
testerl_wrap.obj : error LNK2001: unresolved external symbol _initxreadlines
testerl_wrap.obj : error LNK2001: unresolved external symbol _init_codecs
testerl_wrap.obj : error LNK2001: unresolved external symbol _init_locale
testerl_wrap.obj : error LNK2001: unresolved external symbol _initpcre
testerl_wrap.obj : error LNK2001: unresolved external symbol _initcPickle
testerl_wrap.obj : error LNK2001: unresolved external symbol _initcStringIO
testerl_wrap.obj : error LNK2001: unresolved external symbol _initthread
testerl_wrap.obj : error LNK2001: unresolved external symbol _inittime
testerl_wrap.obj : error LNK2001: unresolved external symbol _initstruct
testerl_wrap.obj : error LNK2001: unresolved external symbol _initstrop
testerl_wrap.obj : error LNK2001: unresolved external symbol _initsha
testerl_wrap.obj : error LNK2001: unresolved external symbol _initsignal
testerl_wrap.obj : error LNK2001: unresolved external symbol _initrotor
testerl_wrap.obj : error LNK2001: unresolved external symbol _initrgbimg
testerl_wrap.obj : error LNK2001: unresolved external symbol _initregex
testerl_wrap.obj : error LNK2001: unresolved external symbol _initoperator
testerl_wrap.obj : error LNK2001: unresolved external symbol _initnt
testerl_wrap.obj : error LNK2001: unresolved external symbol _initmd5
testerl_wrap.obj : error LNK2001: unresolved external symbol _initmath
testerl_wrap.obj : error LNK2001: unresolved external symbol _initimageop
testerl_wrap.obj : error LNK2001: unresolved external symbol _initgc
testerl_wrap.obj : error LNK2001: unresolved external symbol _initerrno
testerl_wrap.obj : error LNK2001: unresolved external symbol _initcmath
testerl_wrap.obj : error LNK2001: unresolved external symbol _initbinascii
testerl_wrap.obj : error LNK2001: unresolved external symbol _initaudioop
testerl_wrap.obj : error LNK2001: unresolved external symbol _initarray
testerl_wrap.obj : error LNK2001: unresolved external symbol 
_PyImport_Inittab
Release/testerl.exe : fatal error LNK1120: 35 unresolved externals
Error executing link.exe.

testerl.exe - 36 error(s), 2 warning(s)





More information about the Python-list mailing list