473,473 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

wrapping C++ code using blitz++ arrays to python using SWIG

1 New Member
Hi there,
I need to use SWIG to wrap my C++ class which heavily uses blitz++ arrays to python. Has anybody done this before? I'm looking for a simple example .i file...

My imports in CFits.h:
Expand|Select|Wrap|Line Numbers
  1.   #include <stdio.h>
  2.   #include <iostream>
  3.   #include <cstdlib>
  4.   #include <blitz/array.h>
  5.   #include <blitz/vector.h>
  6.   #include <blitz/vector-et.h>
  7.   #include <blitz/vecwhere.h>
  8.   #include <blitz/tinyvec.h>
  9.   #include <blitz/tinyvec-et.h>
  10.   #include <fitsio.h>
  11.   #include <fitsio2.h>


My stelladrp.i file:
Expand|Select|Wrap|Line Numbers
  1. %module stelladrp
  2. %{
  3. #include "cfits/src/CAny.h"
  4. #include "cfits/src/CFits.h"
  5. #include "mextract/src/MExtract.h"
  6. %}
  7. %include std_string.i
  8. using std::string;
  9. %include "cfits/src/CAny.h"
  10. %include "cfits/src/CFits.h"
  11. %include "mextract/src/MExtract.h"
my commands:
Expand|Select|Wrap|Line Numbers
  1. swig -c++ -python -I/usr/local/include -I/usr/include stelladrp.i
  2. g++ -lm -fpic -std=c++11 -c mextract/src/MExtract.cpp stelladrp_wrap.cxx -I/usr/include/python2.7/
  3. g++ -shared MExtract.o stelladrp_wrap.o -o _stelladrp.so
my Python output when importing stelladrp:
Expand|Select|Wrap|Line Numbers
  1. >>> import stelladrp
  2. Traceback (most recent call last):
  3.   File "<stdin>", line 1, in <module>
  4.   File "stelladrp.py", line 28, in <module>
  5.     _stelladrp = swig_import_helper()
  6.   File "stelladrp.py", line 24, in swig_import_helper
  7.     _mod = imp.load_module('_stelladrp', fp, pathname, description)
  8. ImportError: ./_stelladrp.so: undefined symbol: _ZNK5CFits6SplIntERN5blitz5ArrayIdLi1EEES3_S3_dPd
  9. >>>
Aug 14 '14 #1
0 1110

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Harish | last post by:
I am using Python2.3 version with SWIG-1.3.19 to access C++ interface provided by a DLL. Some of its function returns MFC class objects like CString , CMap. I tried to generate wrapper for these...
0
by: Bo Peng | last post by:
Dear list, With the help from this list, I have experimented some techniques and I have to say python/c++/swig is wonderful! I still have some questions though: 1. Is there a way to access...
0
by: Helmut Zeisel | last post by:
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...
13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
6
by: Andrew Wilkinson | last post by:
Hi, I'm trying to wrap a C++ class hierarchy with Python types and I'd like to maintain the hierarchy in the types. I'm fairly sure this is possible, isn't it? Are there any documents...
4
by: Bob.Brandt | last post by:
I need to find some way of using Safe Arrays within an ASP without using an external application. Here is the senerio: I have one ASP and sends XML data to another ASP which returns Data from...
11
by: itajit | last post by:
Hi, I'm using python and swig. I'm a begginner and after generating the .cpp and wrap file from swig the compilation of wrap file is giving problem taht can not include python.h, though it is...
25
by: jwrweatherley | last post by:
I'm pretty new to python, but am very happy with it. As well as using it at work I've been using it to solve various puzzles on the Project Euler site - http://projecteuler.net. So far it has not...
16
by: Nkhosinathie | last post by:
hi, i'm writing a program that is using 4 arrays of pointers to char,called article,noun,verb and preposition.the program should create a sentence by selecting a word at random from each array in the...
1
by: Harika | last post by:
hi everybody Iam learning python. I have to write test scripts for c files. I did using swig and python. Using python i give input to a function and gets the output and shown using python script...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
1
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: 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 ...
0
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...

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.