473,462 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create 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("_opcsvcapi",
["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_SOURCE" 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_SvcAPI_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_SvcAPI_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 1685

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

Similar topics

220
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...
699
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...
49
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...
13
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...
5
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...
27
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...
22
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
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 ...

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.