473,748 Members | 7,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

first time use of swig, python and c++ .. it's a mess ... pleaseadvice

Hi,

we have a third-party product that has a C++ api on HP-UX.

I would like be able to use the API in Python (as I remember Python is
good at doing this).

I have no experience with this so I Googled and tried to find some
info on what I had to do.

So, I installed Python 2.4.4 and Swig 1.3.33

The header file to the library is '/opt/OV/include/opcsvcapi.h'.

I created a SWIG file with the following content:
"
%module opcsvcapi
%{
/* Includes the header in the wrapper code */
#include "/opt/OV/include/opcsvcapi.h"
%}

/* Parse the header file to generate wrappers */
%include "/opt/OV/include/opcsvcapi.h"
"
Then I ran the cmd:
# swig -c++ -python opcsvcapi.i
with output:
"
/opt/OV/include/opcsvcapi.h:41: Warning(362): operator= ignored
/opt/OV/include/opcsvcapi.h:46: Warning(503): Can't wrap 'operator
Type' unless renamed to a valid identifier.
"

The result are two files:
opcsvcapi.py
opcsvcapi_wrap. cxx
I created a 'setup.py' file with the following content:
"
import distutils
from distutils.core import setup, Extension

setup(name = "opcsvcapi" ,
version = "1.0",
ext_modules = [Extension("_opc svcapi",
["opcsvcapi.i"," opcsvcapi.cxx"])])
"

Then I run: python setup.py build

This results in an extra file:
opcsvcapi_wrap. c and a 'build' directory

and the following errors:
"
running build
running build_ext
building '_opcsvcapi' extension
swigging opcsvcapi.i to opcsvcapi_wrap. c
swig -python -o opcsvcapi_wrap. c opcsvcapi.i
creating build
creating build/temp.hp-ux-B.11.11-9000-800-2.4
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-
prototypes -fPIC -I/usr/local/include/python2.4 -c opcsvcapi_wrap. c -o
build/temp.hp-ux-B.11.11-9000-800-2.4/opcsvcapi_wrap. o
In file included from /usr/local/include/python2.4/Python.h:8,
from opcsvcapi_wrap. c:118:
/usr/local/include/python2.4/pyconfig.h:851: 1: warning:
"_POSIX_C_SOURC E" redefined
<command line>:1:1: warning: this is the location of the previous
definition
In file included from opcsvcapi_wrap. c:2490:
/opt/OV/include/opcsvcapi.h:12: 18: error: vector: No such file or
directory
In file included from opcsvcapi_wrap. c:2490:
/opt/OV/include/opcsvcapi.h:15: error: expected '=', ',', ';', 'asm'
or '__attribute__' before 'SvcAPI'
opcsvcapi_wrap. c: In function 'Swig_var_SvcAP I_set':
opcsvcapi_wrap. c:2505: error: 'SvcAPI' undeclared (first use in this
function)
opcsvcapi_wrap. c:2505: error: (Each undeclared identifier is reported
only once
opcsvcapi_wrap. c:2505: error: for each function it appears in.)
opcsvcapi_wrap. c:2505: error: 'namespace' undeclared (first use in
this function)
opcsvcapi_wrap. c:2505: error: expected expression before ')' token
opcsvcapi_wrap. c: In function 'init_opcsvcapi ':
opcsvcapi_wrap. c:3064: error: 'Swig_var_SvcAP I_get' undeclared (first
use in this function)
error: command 'gcc' failed with exit status 1
"

and that's it.
Any idea what I am doing wrong?

Any help much appreciated

Kris
Feb 26 '08 #1
0 1724

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
19113
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
699
34065
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
49
2863
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
13
3004
by: Grant Edwards | last post by:
A few months back I wrote a sort of a strip-chart recorder program that talks DeviceNet to a measurement widget and plots the received data in more-or-less real time using the Gnuplot module. It was written on Linux system with absolutely no thought given to portability. It's nothing big (about 650 lines of code). Today, just for fun, I decide to try to run it under Win32. After installing the Numeric and Gnuplot modules, I only had...
5
1713
by: Alan Searle | last post by:
I have an Access 2002 system with a number of reports which all run fine. However, sometimes reports in Landscape format appear in Portrait when you first open them. To get the correct (landscape) formatting all we have to do is to close and re-open the report (no other changes) and then it is OK. Has anyone else come across this problem? I am opening with docmd.openreport and have played around with other (VBA) commands but I really...
27
3788
by: Josh | last post by:
We have a program written in VB6 (over 100,000 lines of code and 230 UI screens) that we want to get out of VB and into a better language. The program is over 10 years old and has already been ported from VB3 to VB6, a job which took over two years. We would like to port it to Python, but we need to continue to offer upgrades and fixes to the current VB6 version. Does anybody know of ways we could go about rewriting this, one screen at a...
22
2048
by: lennart | last post by:
Hi, I'm planning to learn a language for 'client' software. Until now, i 'speak' only some web based languages, like php. As a kid i programmed in Basic (CP/M, good old days :'-) ) Now i want to start to learn a (for me) new computer language. I like Python. Its free, easy to learn and some favorite programs of my are written in Python / can understand Python (like OpenOffice) etc.
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.