« Return to Thread: Integrating C++ (Visual Studio 2009) with python issue

Re: Integrating C++ (Visual Studio 2009) with python issue

by alok.jadhav :: Rate this Message:

Reply to Author | View in Thread


I followed all the steps but it is still not working for me.
I followed a simple hello world program at following site.. But it still
gives me error.

http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B

It is supposed to work fine but I get error


C:\Project\TickCollector\temp2>python setup.py build
running build
running build_ext
building 'hello' extension
creating build
creating build\temp.win32-2.6
creating build\temp.win32-2.6\Release
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo
/Ox /MD /W
3 /GS- /DNDEBUG -IC:\Python26\include -IC:\Python26\PC
/Tphellomodule.cpp /Fobui
ld\temp.win32-2.6\Release\hellomodule.obj
hellomodule.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) :
warning C
4530: C++ exception handler used, but unwind semantics are not enabled.
Specify
/EHsc
creating build\lib.win32-2.6
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL
/nologo /INCRE
MENTAL:NO /LIBPATH:C:\Python26\libs /LIBPATH:C:\Python26\PCbuild
/EXPORT:inithel
lo build\temp.win32-2.6\Release\hellomodule.obj
/OUT:build\lib.win32-2.6\hello.p
yd /IMPLIB:build\temp.win32-2.6\Release\hello.lib
/MANIFESTFILE:build\temp.win32
-2.6\Release\hello.pyd.manifest
LINK : error LNK2001: unresolved external symbol inithello
build\temp.win32-2.6\Release\hello.lib : fatal error LNK1120: 1
unresolved exter
nals
error: command '"C:\Program Files\Microsoft Visual Studio
9.0\VC\BIN\link.exe"'
failed with exit status 1120

Which is a linker error. Unresolved externals. "LINK : error LNK2001:
unresolved external symbol inithello"

Regards, Alok

 

-----Original Message-----
From: William Fulton [mailto:william@...] On Behalf Of
William S Fulton
Sent: Friday, October 16, 2009 11:00 PM
To: Jadhav, Alok
Cc: swig-user@...
Subject: Re: [Swig-user] Integrating C++ (Visual Studio 2009) with
python issue

alok.jadhav wrote:
> Hello guys. I am using SWIG for the first time to use a C++ library in

> pythong project.
> To start with, I am trying to build a very simple C++ extension given
> in following link. Probably most basic example. The example is from
> the SWIG site  http://www.swig.org/tutorial.html SWIG example I have a

> windows XP machine. I am using Microsoft Visual Studio 2008 (SP1) for
> C++ compiler.
> Also My setup.py file looks like as below..
>
>
> from distutils.core import setup, Extension
>
> example_module = Extension('_example',
>                                     sources=['example.i'],
>                                     swig_opts=[-c++'],
> )
>
>
> setup (name = 'Example',
>           version = "0.1",
>           description = "SWIG example""",
>           ext_modules = [example_module],
>           py_modules = ["Example"],
> )
>
>
> When I try to compile using
>> python setup.py build.txt
>
> I get quite a few compilation error.
>
> The errors are as follows :
>
> ..
> ..
> ..
> creating build\lib.win32-2.6
> C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL
> /nologo /INCRE MENTAL:NO /LIBPATH:C:\Python26\libs
> /LIBPATH:C:\Python26\PCbuild /EXPORT:init_ex ample
> build\temp.win32-2.6\Release\example_wrap.obj
> /OUT:build\lib.win32-2.6\_ex
> ample.pyd /IMPLIB:build\temp.win32-2.6\Release\_example.lib
> /MANIFESTFILE:build\
> temp.win32-2.6\Release\_example.pyd.manifest
>    Creating library build\temp.win32-2.6\Release\_example.lib and
> object build\t emp.win32-2.6\Release\_example.exp
> example_wrap.obj : error LNK2019: unresolved external symbol "double
> My_variable " (?My_variable@@3NA) referenced in function
> _Swig_var_My_variable_set example_wrap.obj : error LNK2019: unresolved

> external symbol "int __cdecl fact(i nt)" (?fact@@YAHH@Z) referenced in

> function __wrap_fact example_wrap.obj : error LNK2019: unresolved
> external symbol "int __cdecl my_mod (int,int)" (?my_mod@@YAHHH@Z)
> referenced in function __wrap_my_mod example_wrap.obj : error LNK2019:

> unresolved external symbol "char * __cdecl get _time(void)"
> (?get_time@@YAPADXZ) referenced in function __wrap_get_time
> build\lib.win32-2.6\_example.pyd : fatal error LNK1120: 4 unresolved
> externals
> error: command '"C:\Program Files\Microsoft Visual Studio
> 9.0\VC\BIN\link.exe"'
> failed with exit status 1120
>
> I tried to google for above but I could not find anything.
>
> Most of the solutions I found are valid for older versions of Visual
> Studio environment.
>
> I feel there maybe some issue with the new compiler ?
>
> Has anyone worked on Visual Studio 2009 and python?
>
> This seems like a simple problem but I haven't been able to solve it.
> Please help.
>
> Regards, Alok

The Windows documentation explains how to use the example Visual Studio
project files distributed with SWIG and with the minimal of fuss. This
is much easier for getting going.

William

===============================================================================
 Please access the attached hyperlink for an important electronic communications disclaimer:
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 ===============================================================================
 

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Integrating C++ (Visual Studio 2009) with python issue